Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: sgee <jaakko.laa@gm...>  20110118 23:33:14

I'm a CFD student and I wish to learn to make highquality plots from my calculations using matplotlib. However, I'm a complete novice in using matplotlib and python and I didn't find any earlier posts so here goes. I have data form Ansys Fluent in the following form continuity xvelocity yvelocity energy k epsilon 1 0.00011115784 1.5359586e07 1.0506172e07 0.0032920227 0.40809903 1 0.16584706 0.0047719572 2.7355736e07 0.026478255 0.19814095 0.5674 0.044237841 0.0026294924 2.8202695e07 0.030139321 0.13935529 The first line is for the first iteration, the second line for the second iteration etc. Basically, I would like to have plot this data and have a picture like http://openfoamwiki.net/images/f/ff/Pump_residuals.png this Any help would be much appreciated. BR Jack  View this message in context: http://old.nabble.com/BeginnerandplottingCFDdatafromfiletp30705461p30705461.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Benjamin Root <ben.root@ou...>  20110120 01:27:58
Attachments:
Message as HTML

On Tue, Jan 18, 2011 at 5:33 PM, sgee <jaakko.laa@...> wrote: > > I'm a CFD student and I wish to learn to make highquality plots from my > calculations using matplotlib. However, I'm a complete novice in using > matplotlib and python and I didn't find any earlier posts so here goes. > > I have data form Ansys Fluent in the following form > continuity xvelocity yvelocity energy > k epsilon > 1 0.00011115784 1.5359586e07 1.0506172e07 > 0.0032920227 > 0.40809903 > 1 0.16584706 0.0047719572 2.7355736e07 > 0.026478255 0.19814095 > 0.5674 0.044237841 0.0026294924 2.8202695e07 0.030139321 > 0.13935529 > > The first line is for the first iteration, the second line for the second > iteration etc. Basically, I would like to have plot this data and have a > picture like http://openfoamwiki.net/images/f/ff/Pump_residuals.png this > > Any help would be much appreciated. > > BR Jack > Jack, First, you would load your data using numpy's loadtxt() function. You can tell loadtxt() to skip the first line since it is a header. This will give you a 2D array (n rows and 6 columns) where n is the number of iterations. You can then plot the data using matplotlib's plot command (or semilogy to automatically get ylog scaling), passing in the first column for the x data, and then the other columns for the y data. So, your code would look something like this: import numpy as np import matplotlib.pyplot as plt data = np.loadtxt('foobar.txt', skiprows=1) plt.semilogy(data[:, 0], data[:, 1:]) plt.xlabel('Iteration') plt.ylabel('Residuals') plt.legend(['Ux_0', 'Uy_0', 'p_0', 'k_0', 'epsilon_0']) plt.show() That should get you a similar plot. There are more things you can do to control various aspects, but this should get you a good start. I hope this helps! Ben Root 
From: Jack L. <jaakko.laa@gm...>  20110120 22:55:56

Ben, thanks for your advice! With a little modification of your code I got what I was after for. BR Jack  View this message in context: http://old.nabble.com/BeginnerandplottingCFDdatafromfiletp30705461p30724168.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
Sign up for the SourceForge newsletter:
No, thanks