Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I would like to know if someone has an easy program to plot Planetary Boundary Layer height on a map (2D in lat/lon) in fortran 90 or python (or NCL).
I am using a program in F.90 but it is not working so I would like to compare with a second program.
Thank you
Here's a Python example with matplotlib and netCDF4 modules:
import matplotlib.pyplot as plt
from netCDF4 import Dataset
nc = Dataset('mydatafile.nc','r')
lon = nc.variables['lon'][:]
lat = nc.variables['lat'][:]
pblh = nc.variables['pblh'][:]
nc.close()
plt.contourf(lon,lat,pblh)
plt.colorbar()
plt.savefig('pblh.png')
ptl.clf()
You may need to edit this example to match your data, e.g. filename, variable names etc.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
The library mplfinance offers a good possibility to perform OHLC plotting with Python/Matplotlib. Nevertheless I want to / have to build a small application that does a kind of OHLC plotting by itself.
I am wondering how I should perform the (huge) amount of vertical and horizontal bars by myself.
Is it the best to do a plt.plot() for all the data I have or is there a more performant way to do this using matplotlib?
Snippet of mplfinance output
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So essentially I have a few numbered files like output_0000.dat ... output_1999.dat that each correspond to a consecutive timestep in the simulation of a wave on a string. The files contain the x and y positions for each point on the string at that timestep.
My goal is to plot these files one after another to make an animation, ideally using matplotlib but other software will also do.
If you could also direct me to a helpful tutorial, I'll be very greatful.
Thanks!
The animation tutorial suggested by #tom are probably the ideal solution, however the simplest way to do what you want is to use interactive plotting with filenames padded by zeros and numpy's genfromtxt,
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
plt.show()
for i in range(2000):
filename = "output_{0:04d}.dat".format(i)
print("printing file = ", filename)
xy = np.genfromtxt(filename)
x = xy[:,0]; y = xy[:,1]
plt.plot(x,y)
plt.pause(0.01)
You may need to add delimiter to genfromtxt depending on the format of the data in your files.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How would I make an interactive plot like the one displayed here? I'd like to show an image with x and y slices of the image taken at a point that can be adjusted by clicking on the image.
I know this one was made in Chaco, but since Chaco isn't compatible with python3, just matplotlib or bokeh would be preferable.
Using tacaswells suggestion, I found that the cross_section_2d in bubblegum was just what I was looking for.
First I installed bubblegum from github https://github.com/Nikea/bubblegum.git
Then the following sets up a cross_section image
import matplotlib.pyplot as plt
import numpy as np
from bubblegum.backend.mpl.cross_section_2d import CrossSection
fig= plt.figure()
cs= CrossSection(fig)
img= np.random.rand(100,100)
cs.update_image(img)
plt.show()
Thanks!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Input:
import scipy.misc
import matplotlib.pyplot
matplotlib.pyplot.imshow(scipy.misc.lena())
The following code displays an image of a woman on a 500 x 500 grid. My questions are as follows:
1.Is this technically considered a graph? (From my knowledge a graph is the relationship between an x coordinate to a y coordinate, this seems to not be the case, but the numbers on the sides makes it confusing)
2.What do the numbers on the x and y axis represent? Is that only the sizing?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm wondering if it's possible to plot a contour (level curves) graphic from a 2D image in Python. More specific, I'm wondering how could I read an image data (the set of the grayscale pixels, for example), and use it for the z input
I'm reading some articles about the matplotlib but I couldn't find an example which the input is an image.
You can use the function contour from matplotlib.
import numpy as np
import pylab as plt
# Sample data
row = np.linspace(-2,2,20)
X,Y = np.meshgrid(row,row)
Z = np.exp(-((X-1.5)**2+(Y+1)**2))
Z += np.exp(-((X)**2+(Y)**2))
plt.subplot(121)
plt.imshow(Z,interpolation='none',origin='lower')
plt.subplot(122)
plt.contour(X,Y,Z)
plt.show()
print X,Y
You can also fill them in with contourf instead