Skip to content
Advertisement

Tag: matplotlib

Histogram Matplotlib

So I have a little problem. I have a data set in scipy that is already in the histogram format, so I have the center of the bins and the number of events per bin. How can I now plot is as a histogram. I tried just doing but it didn’t like that. Any recommendations? Answer The object-oriented interface is

Plot smooth line with PyPlot

I’ve got the following simple script that plots a graph: As it is now, the line goes straight from point to point which looks ok, but could be better in my opinion. What I want is to smooth the line between the points. In Gnuplot I would have plotted with smooth cplines. Is there an easy way to do this

How to put the legend outside the plot

I have a series of 20 plots (not subplots) to be made in a single figure. I want the legend to be outside of the box. At the same time, I do not want to change the axes, as the size of the figure gets reduced. I want to keep the legend box outside the plot area (I want the

slicing a 2d numpy array

The following code: Is generating the following error message: I looked up the syntax at this link and I seem to be using the correct syntax to slice. However, when I type into the Python shell, it gives me the following output, which is clearly wrong, and is probably what is throwing the error: Can anyone show me how to

Get legend as a separate picture in Matplotlib

I’m developing a Web application and want to display a figure and its legend in different locations on the page. Which means I need to save the legend as a separate png file. Is this possible in Matplotlib in a more or less straightforward way? Answer This could work:

How to update a plot in matplotlib

I’m having issues with redrawing the figure here. I allow the user to specify the units in the time scale (x-axis) and then I recalculate and call this function plots(). I want the plot to simply update, not append another plot to the figure. Answer You essentially have two options: Do exactly what you’re currently doing, but call graph1.clear() and

How to change the font size on a matplotlib plot

How does one change the font size for all elements (ticks, labels, title) on a matplotlib plot? I know how to change the tick label sizes, this is done with: But how does one change the rest? Answer From the matplotlib documentation, This sets the font of all items to the font specified by the kwargs object, font. Alternatively, you

Matplotlib runs out of memory when plotting in a loop

I have a fairly simple plotting routine that looks like this: When I plot this in single iterations, it works fine. However, the moment I put it in a loop, matplotlib throws a hissy fit… This happens on iteration 2 (counting from 1), if that makes a difference. The code is running on Windows XP 32-bit with python 2.5 and

Hiding axis text in matplotlib plots

I’m trying to plot a figure without tickmarks or numbers on either of the axes (I use axes in the traditional sense, not the matplotlib nomenclature!). An issue I have come across is where matplotlib adjusts the x(y)ticklabels by subtracting a value N, then adds N at the end of the axis. This may be vague, but the following simplified

Advertisement