matplotlib

Is it possible to plot implicit equations using Matplotlib?

Hello all - many thanks again to people who have kindly offered help (especially to Mark for his outstanding response to my previous question). I would like to plot implicit equations (of the form f(x,y)=g(x,y) eg. x^y=y^x) in Matplotlib. Is this possible? All the best, Geddes ...

How to format contour lines from Matplotlib

Hello - I am working on using Matplotlib to produce plots of implicit equations (eg. y^x=x^y). With many thanks to the help I have already received I have got quite far with it. I have used a contour line to produce the plot. My remaining problem is with formatting the contour line eg width, color and especially zorder, where the contour...

Variable alpha blending in pylab

How does one control the transparency over a 2D image in pylab? I'd like to give two sets of values (X,Y,Z,T) where X,Y are arrays of positions, Z is the color value, and T is the transparency to a function like imshow but it seems that the function only takes alpha as a scalar. As a concrete example, consider the code below that attempt...

how to get string type X values in matplotlib

I am using matplotlib for a graphing application. I am trying to create a graph which has strings as X values. I cannot do this ( using plot function ) because it's expecting a numaric value for X. How can I get string X values ( for example, build-lables as X values ) ? ...

matplotlib: How to adjust ticks at the corner of a 3Dplot with mplot3d

Hey hello, the problem I'm facing at the moment is the lack of ticks at the corners of the 3D-plots from matplotlib.mplot3d. Say the xaxis ranges from 0 to 10, then only the ticks 2,4,6 and 8 will be displayed. What I'm looking for is a way to format the ticks similiar to pylab: from pylab import * plot([1,2,3]) xticks([0, 1, 2], ['a',...

Anyone knows a matplotlib equivalent in C or C++

I've been using matplotlib in a Python project. It is great. I have now to plot data in a C++ project. Is anyone aware of a plotting library in C or C++? Note that I cannot accept GPL licensed libraries. ...

Matplotlib not showing up in Mac OSX

Hi, I am running Mac OSX 10.5.8. I installed matplotlib using macports. I get some examples from the matplotlib gallery like this one, without modification: http://matplotlib.sourceforge.net/examples/api/unicode_minus.html I run it, get no error, but the picture does not show up. In Linux Ubuntu I get it. Do you know what could be wr...

How to copy matplotlib figure?

I have FigureCanvasWxAgg instance with a figure displayed on a frame. If user clicks on the canvas another frame with a new FigureCanvasWxAgg containing the same figure will be shown. By now closing the new frame can result in destroying the C++ part of the figure so that it won't be available for the first frame. How can I save the fi...

Matplotlib canvas drawing

Let's say I define a few functions to do certain matplotlib actions, such as def dostuff(ax): ax.scatter([0.],[0.]) Now if I launch ipython, I can load these functions and start a new figure: In [1]: import matplotlib.pyplot as mpl In [2]: fig = mpl.figure() In [3]: ax = fig.add_subplot(1,1,1) In [4]: run functions # run the f...

Sans-serif math with latex in matplotlib

The following script: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as mpl mpl.rc('font', family='sans-serif') mpl.rc('text', usetex=True) fig = mpl.figure() ax = fig.add_subplot(1,1,1) ax.text(0.2,0.5,r"Math font: $451^\circ$") ax.text(0.2,0.7,r"Normal font (except for degree symbol): 451$^\circ$") fig.savefig('te...

How do I set a matplotlib colorbar extents?

I'd like to display a colorbar representing an image's raw values along side a matplotlib imshow subplot which displays that image, normalized. I've been able to draw the image and a colorbar successfully like this, but the colorbar min and max values represent the normalized (0,1) image instead of the raw (0,99) image. f = plt.figure(...

HOW TO: Draggable legend in matplotlib

QUESTION: I'm drawing a legend on an axes object in matplotlib but the default positioning which claims to place it in a smart place doesn't seem to work. Ideally, I'd like to have the legend be draggable by the user. How can this be done? SOLUTION: Well, I found bits and pieces of the solution scattered among mailing lists. I've come...

how to handle an asymptote/discontinuity with Matplotlib

Hello all. Firstly - thanks again for all your help. Sorry not to have accepted the responses to my previous questions as I did not know how the system worked (thanks to Mark for pointing that out!). I have since been back and gratefully acknowledged the kind help I have received. My question: when plotting a graph with a discontinuity/...

How can I draw a log-normalized imshow plot with a colorbar representing the raw data in matplotlib

I'm using matplotlib to plot log-normalized images but I would like the original raw image data to be represented in the colorbar rather than the [0-1] interval. I get the feeling there's a more matplotlib'y way of doing this by using some sort of normalization object and not transforming the data beforehand... in any case, there could ...

Python - animation with matplotlib.pyplot

How can one create animated diagrams using popular matplotlib library? I am particularly interested in animated gifs. ...

Setting `axes.linewidth` without changing the `rcParams` global dict

So, it seems one cannot do the following (it raises an error, since axes does not have a set_linewidth method): axes_style = {'linewidth':5} axes_rect = [0.1, 0.1, 0.9, 0.9] axes(axes_rect, **axes_style) and has to use the following old trick instead: rcParams['axes.linewidth'] = 5 # set the value globally ... # some code rcdefaul...

Matplotlib digit grouping (decimal separator)

Basically, when generating plots with matplotlib, The scale on the y-axis goes into the millions. How do I turn on digit grouping (i.e. so that 1000000 displays as 1,000,000) or turn on the decimal separator? ...

How can I plot NaN values as a special color with imshow in matplotlib?

I am trying to use imshow in matplotlib to plot data as a heatmap, but some of the values are NaNs. I'd like the NaNs to be rendered as a special color not found in the colormap. example: import numpy as np import matplotlib.pyplot as plt f = plt.figure() ax = f.add_subplot(111) a = np.arange(25).reshape((5,5)).astype(float) a[3,:] = n...

matplotlib - changing rect colours on the fly

I am playing with matplotlib - I have a bar chart, and I want to highlight the bar which user clicks. I have a callback that goes through a rect collection (the one I got from self.axis.bar(...)) and finds out which one was clicked (looking at the coordinates). At this point I want to call something to change the colour of the current ba...

Histogram in Matplotlib with input file

I wish to make a Histogram in Matplotlib from an input file containing the raw data (.txt). I am facing issues in referring to the input file. I guess it should be a rather small program. Any Matplotlib gurus, any help ? I am not asking for the code, some inputs should put me on the right way ! ...