Skip to content

Tag: matplotlib

Matplotlib different size subplots

I need to add two subplots to a figure. One subplot needs to be about three times as wide as the second (same height). I accomplished this using GridSpec and the colspan argument but I would like to do this using figure so I can save to PDF. I can adjust the first figure using the figsize argument in the

Pip install Matplotlib error with virtualenv

I am trying to install matplotlib in a new virtualenv. When I do: or I get this error: Anyone have an idea what is going on? Any help much appreciated. Answer Building Matplotlib requires libpng (and freetype, as well) which isn’t a python library, so pip doesn’t handle installing it (or freetype)…

How to plot a gradient color line in matplotlib?

To state it in a general form, I’m looking for a way to join several points with a gradient color line using matplotlib, and I’m not finding it anywhere. To be more specific, I’m plotting a 2D random walk with a one color line. But, as the points have a relevant sequence, I would like to loo…

set matplotlib 3d plot aspect ratio

Setting the aspect ratio works for 2d plots: But does not for 3d: Is there a different syntax for the 3d case, or it’s not implemented? Answer My understanding is basically that this isn’t implemented yet (see this bug in GitHub). I’m also hoping that it is implemented soon. See This link fo…

How can I set the aspect ratio in matplotlib?

I’m trying to make a square plot (using imshow), i.e. aspect ratio of 1:1, but I can’t. None of these work: It seems like the calls are just being ignored (a problem I often seem to have with matplotlib). Answer Third times the charm. My guess is that this is a bug and Zhenya’s answer sugges…

Make matplotlib autoscaling ignore some of the plots

I use matplotib’s Axes API to plot some figures. One of the lines I plot represents the theoretical expected line. It has no meaning outside of the original y and x limits. What I want, is for matlplotlib to ignore it when autoscaling the limits. What I used to do, is to check what are the current limit…