How can I output a matplotlib figure to a shapefile? - matplotlib

I want to create a contour plot with matlibplot and generate a shapefile from it so that I can use it in QGIS to display it.
Though it is possible to plot a map with matplotlib and then overlay with my contour plot, the choices of map sources are limited. It would be easier to export the contour plot in a shapefile and loaded in QGIS with a customized map.
Thanks!

There is a contour plugin available in QGIS, and it is based on the contouring functions of matplotlib. It's still a little bit buggy but hopefully that will be corrected in the future.

Related

How to plot xyz point data using deck.gl

Im very new to DeckGL and was wondering if I can plot regular data on it. For example I have a Datset of Points that I would like to plot. But I havent had much sucess using the Scatterplot layer (https://deck.gl/examples/scatterplot-layer/). I think DeckGL expects me to supply geoCoordinates but I want to plot XYZ plots using it. Is this possible to do? I tried to emulate the 3d point cloud example - but that really didnt work very well for me.

matplotlib: box plot for each category

My pandas data frame has two columns: category and duration. And
I use the following code to make a box plot of all data points.
import matplotlib.pyplot as plt
plt.boxplot(df.duration)
plt.show()
However, if I want one box fore each category, how do I modify the above code? Thanks!
In addition to Wen's answer, which is spot on, you might want to check out the seaborn library. It was made to do this kind of plot.
Seaborn is a Python visualization library based on matplotlib. It
provides a high-level interface for drawing attractive statistical
graphics.
Check the documentation for boxplots
Draw a box plot to show distributions with respect to categories.
sns.boxplot(data=df, x='category', y='duration')
We can do it with pandas
#df=pd.DataFrame({'category':list('aacde'),'duration':[1,3,2,3,4]}) sample data
df.assign(index=df.groupby('category').cumcount()).pivot('index','category','duration').plot(kind='box')

How to plot a vector field with error ellipse using cartopy

Cartopy seems like a great tool for Geoscience, but it appears to lack a method for plotting vector data on a map together with their error ellipses. Is there a straightforward way to add error ellipses centered on the tips of vector data?
Cartopy inherits all its vector plotting functionality from matplotlib. Cartopy provides a way to project the vectors, but they are drawn by matplotlib. I haven't heard of a feature you describe in matplotlib, so I'm afraid the answer is probably no.

Matplotlib scatter plot with density histograms on the sides

I don't know any way to describe this plot, but I need to do it preferably with matplotlib. If there is a name for this plot, I would love to know it.
It can be found on page 10 of this PLOS ONE paper (Figure 6): http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0093590
Basically, each section is made up of three plots. One scatter plot, and two histograms that show the density of points in each region, one for each axis.
Any help would be great. Thanks.

3d Visualisation in matplotlib

I am using matplotlib for visualisation. I need 3d visualisation and also the animations in my visualisation. I have searched about the 3d visualisation and animation in matplotlib but get nothing useful information. Is it possible or not to use matplotlib for 3d visuallisation and animations. What are the links that I can study about it ?
Animation and 3D plot are available on mplot3d library. Take a look at wire3d_animation and mayavi Animation.
Here is what I, probably most of people, use for python numpy plotting.
For 2D figure plotting, use matplotlib.
For 3D surface and volume plotting, use mayavi.
Both of them come with their own approaches of animating plots. Nevertheless, moviepy is a great alternative approach.