Skip to content

Tag: matplotlib

Save Matplotlib figure as TIFF

Does anyone know how to save a Matplotlib figure as *.tiff? It seems that this format is not supported in Python, while the journals are quite often ask for that format. I am adding some minimal code: This works: But this does not: Answer This is great! Thanks ot Martin Evans. However, for those who would lik…

Get data points from Seaborn distplot

I use to plot a univariate distribution of observations. Still, I need not only the chart, but also the data points. How do I get the data points from matplotlib Axes (returned by distplot)? Answer You can use the matplotlib.patches API. For instance, to get the first line: This returns two numpy arrays conta…

Hide tick label values but keep axis labels

I have this image: I want to hide the numbers; if I use: …I get this image: It also hide the labels, V and t. How can I keep the labels while hiding the values? Answer If you use the matplotlib object-oriented approach, this is a simple task using ax.set_xticklabels() and ax.set_yticklabels(). Here we c…

Dealing with masked coordinate arrays in pcolormesh

I’m working on visualizing some climate model output. The computation is done on a projected latitude/longitude grid. Since the model is simulating sea ice, all land grid cells are masked. The standard tools for plotting geographical information in Python are Basemap and Cartopy, both of which use matpl…

Contourf on the faces of a Matplotlib cube

I am trying to ‘paint’ the faces of a cube with a contourf function using Python Matplotlib. Is this possible? This is similar idea to what was done here but obviously I cannot use patches. Similarly, I don’t think I can use add_collection3d like this as it only supports PolyCollection, Line…