matplotlib

MATLAB to Python Code conversion (NumPy, SciPy, MatplotLib?)

I'm trying to convert the following code to Python from MATLAB for an EEG Project (partly because Python's slightly cheaper!) Hopefully someone can point me in the right direction: I've started to alter it but got bogged down: Particularly trying to find equivalent functions. Tried scipy.org (NumPy_for_Matlab_Users etc.) but I'm not s...

matplotlib: how to hide grey border around the plot

Hi! I'd like to save figurecanvas as bitmap and don't need grey border around the plot in it. How can I hide this? ...

Reusing module references in Python (Matplotlib)

I think I may have misunderstood something here... But here goes. I'm using the psd method in matplotlib inside a loop, I'm not making it plot anything, I just want the numerical result, so: import pylab as pyl ... psdResults = pyl.psd(inputData, NFFT=512, Fs=sampleRate, window=blackman) But that's being looped 36 times every time I ...

How to switch axes in matplotlib?

Hi. I like to switch x axis with y axis after plotting a graph with matplotlib? Any easy way for it? Thanks in advance. ...

Matplotlib runs out of memory when plotting in a loop - EDITED

I have a fairly simple plotting routine that looks like this: from __future__ import division import datetime import matplotlib matplotlib.use('Agg') from matplotlib.pyplot import figure, plot, show, legend, close, savefig, rcParams import numpy from globalconstants import * def plotColumns(columnNumbers, t, out, showFig=False, fil...

Generate a heatmap in MatPlotLib using a scatter data set

I have a set of X,Y data points (about 10k) that are easy to plot as a scatter plot but that I would like to represent as a heatmap. I looked through the examples in MatPlotLib and they all seem to already start with heatmap cell values to generate the image. Is there a method that converts a bunch of x,y, all different, to a heatmap (...

How can I show figures separately in matplotlib?

Say that I have two figures in matplotlib, with one plot per figure: import matplotlib.pyplot as plt f1 = plt.figure() plt.plot(range(0,10)) f2 = plt.figure() plt.plot(range(10,20)) Then I show both in one shot plt.show() Is there a way to show them separately, i.e. to show just f1? Or better: how can I manage the figures separat...

Accented characters in matplotlib

Does anyone know a way to get matplotlib to render accented chars (é,ã,â,etc)? For instance i'm trying to use accented chars on set_yticklabels() and matplot renders squares instead, and when i use unicode() it renders the wrong chars. Is there a way to make this work? Thanks in advance, Jim. Update Turns out you can use u"éã" but f...

How can I produce student-style graphs using matplotlib?

I am experimenting with matplotlib at the moment. Some time ago I used Excel VBA code to produce images such as the one attached. You will notice it is not presented in a scientific/research style but rather as if produced by a school-student on graph paper - with three different grid-line styles. Is there a fairly straightforward way ...

How to make the angles in a matplotlib polar plot go clockwise with 0° at the top?

I am using matplotlib and numpy to make a polar plot. Here is some sample code: import numpy as N import matplotlib.pyplot as P angle = N.arange(0, 360, 10, dtype=float) * N.pi / 180.0 arbitrary_data = N.abs(N.sin(angle)) + 0.1 * (N.random.random_sample(size=angle.shape) - 0.5) P.clf() P.polar(angle, arbitrary_data) P.show() You wil...

Matplotlib subplots_adjust hspace so titles and xlabels don't overlap ?

With say 3 rows of subplots in matplotlib, xlabels of one row can overlap the title of the next; one has to fiddle with pl.subplots_adjust( hspace ), annoying. Is there a recipe for hspace that prevents overlaps and works for any nrow ? """ matplotlib xlabels overlap titles ? """ import sys import numpy as np import pylab as pl nrow = ...

matplotlib: how to refresh figure.canvas

Hello, I can't understand how to refresh FigureCanvasWxAgg instance. Here is the example: import wx import matplotlib from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.figure import Figure class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, wx.NewId(...

Problem running python/matplotlib in background after ending ssh session.

Hi there, I have to VPN and then ssh from home to my work server and want to run a python script in the background, then log out of the ssh session. My script makes several histogram plots using matplotlib, and as long as I keep the connection open everything is fine, but if I log out I keep getting an error message in the log file I cre...

Creating a Colormap Legend in Matplotlib

Hi fellow Stackers! I am using imshow() in matplotlib like so: import numpy as np import matplotlib.pyplot as plt mat = '''SOME MATRIX''' plt.imshow(mat, origin="lower", cmap='gray', interpolation='nearest') plt.show() How do I add a legend showing the numeric value for the different shades of gray. Sadly, my googling has not uncover...

Matplotlib installation problems

Hi, I need to install matplotlib in a remote linux machine, and I am a normal user there. I downlodad the source and run python setup.py build but I get errors, related with numpy, which is not installed, so I decieded to install it first. I download and compile with python setup.py build My question now is, how do I tell to te...

How to stop Python program execution in IDLE

I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c do...

Weird graphics in matplotlib when changing the scale

Hi, I get a histogram picture in matplotlib which looks great. Now I realize I need a log scale on the y-axis, so I just add to the code: ax.set_yscale('log') but then, the histogram bars dissapear and I only get some sparse points, do you know waht could be the reason? Thanks ...

Python or matplotlib limitation error

Hi, I wrote an algorithm using python and matplotlib that generates histograms from some text input data. When the number of data input is approx. greater than 15000, I get in the (append) line of my code: mydata = [] for i in range(len(data)): mydata.append(string.atof(data[i])) the error: Traceback (most recent call last): F...

Python crashes when plotting with matplotlib in module importing swig generated wrapper

I have a python module that imports a module generated with swig. When I try to call the show() function of matplotlib later in that module, python crashes without any hint, what went wrong. When I comment the import statement with the swig generated module out, everything works fine. Does anybody have a clue to what could be the reason ...

PyLab - changing text color and background fill color of text box

Hey all, I'm using PyLab to make some graphs in Python. I want to make a text box that is colored magenta with black text, but cannot get the text to be black. text(x, y, 'Summary', backgroundcolor = 'm', color = 'k') This gives me a magenta background and then text that is almost just as pink. Any ideas what I'm doing wrong? Many th...