pylab

Scaling the y-axis with matplotlib in python

Does anybody know how to scale the y-axis with matplotlib? I don't want to change the y-limit, I just want to extend the physical space. ^ ^ | | | | +----> | Before +----> After Thanks! ...

Is there a way to reduce scipy/numpy precision to reduce memory consumption ?

On my 64-bit Debian/Lenny system (4GByte RAM + 4GByte swap partition) I can successfully do: v=array(10000*random([512,512,512]),dtype=np.int16) f=fftn(v) but with f being a np.complex128 the memory consumption is shocking, and I can't do much more with the result (e.g modulate the coefficients and then f=ifftn(f) ) without a MemoryEr...

both a top and a bottom axis in pylab (e.g. w/ different units) (or left and right)

I'm trying to make a plot with pylab/matplotlib, and I have two different sets of units for the x axis. So what I would like the plot to have is two axis with different ticks, one on the top and one on the bottom. (E.g. one with miles and one with km or so.) A picture says more than a thousand words. Something like the graph below (but ...

Python plotting libraries

What alternatives are there to pylab for plotting in python? In particular, I'm looking for something that doesn't use the stateful model that pylab does. ...

find length of sequences of identical values in a numpy array

In a pylab program (which could probably be a matlab program as well) I have a numpy array of numbers representing distances: d[t] is the distance at time t (and the timespan of my data is len(d) time units). The events I'm interested in are when the distance is below a certain threshold, and I want to compute the duration of these even...

How to scale matplotlib subplot heights individually

Using matplotlib/pylab.... How do I plot 5 heatmaps as subplots which have the same number of columns but different row counts? In other words, I need each subplot's height to be scaled differently. Perhaps an image better illustrates the problem... I need the data points to all be square, AND the columns to be lined up, so the heig...

Displaying X and y axis in pylab

Is there a way in pylab to display the X and Y axis? I know using grid() will display them, but it comes with numerous other lines all given the same emphasis. ...

Resize a figure automatically in matplotlib

Is there a way to automatically resize a figure to properly fit contained plots in a matplotlib/pylab image? I'm creating heatmap (sub)plots that differ in aspect ratio according to the data used. I realise I could calculate the aspect ratio and manually set it, but surely there's an easier way? ...

Sharing contour plot attributes between subplots

I'm plotting several contour plots side by side for visualizing the time evolution of certain function. I want each contour's value and color to be shared between all subplots, but each time I add a new subplot, the contour values are recomputed (as shown in the image below), so any comparison between them is meaningless. I've tried s...

tail read a growing dynamic file and extract two columns and then print a graph.

whats the best way to read a 1 GB file that gets time series data logged in it and generate a real time graph with two of its columns (one time and other a number)? I see that you have different ways of tailign the file. ...

Matplotlib: draw grid lines behind other graph elements

In Matplotlib, I make dashed grid lines as follows: fig = pylab.figure() ax = fig.add_subplot(1,1,1) ax.yaxis.grid(color='gray', linestyle='dashed') however, I can't find out how (or even if it is possible) to make the grid lines be drawn behind other graph elements, such as bars. Changing the order of adding the grid versus addin...

Why won't my Python scatter plot work?

I created a very simple scatter plot using pylab. pylab.scatter(engineSize, fuelMile) pylab.show() The rest of the program isn't worth posting, because it's that line that's giving me the problem. When I change "scatter" to "plot" it graphs the data, but each point is part of a line and that makes the whole things a scribbly mess. I j...

How to use python, PyLab, NumPy, etc for my Physics lab class over excel

Hey all, I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better than excel's capabili...

Vertical xtick labels on top, not bottom

I want to plot a confusion matrix using Pylab. The class labels along the horizontal axis are long, so I want to plot them rotated vertically. However, I also want to plot them on top of the axis, not below. This command can plot vertical labels on bottom: pylab.imshow(confusion_matrix) pylab.xticks(..., rotation='vertical') and this...

Python library needed

I am trying to run a python script which has the following statements: import random as RD import pylab as PL import scipy as SP import networkx as NX Where can I download these packages? I have installed these packages and I get the following error when I run my code I am getting the following error when I run the code Traceback (...

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 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...

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 = ...

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...

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...