How I can plot a chart like this ?

Tuesday, March 30th, 2010 | Uncategorized

I want to plot charts like above (using gnuplot/ matplotlib / anything). I have my data in a text file. Can someone please point me to an example ?

The post is brought to you by lekhonee v0.8

15 Comments to How I can plot a chart like this ?

Tom "spot" Callaway
March 30, 2010

You can do this with R.

See: http://www.harding.edu/fmccown/R/

Elliott
March 30, 2010

That looks simple enough for gnuplot. I find this site pretty useful (and has a two-axis example):
http://t16web.lanl.gov/Kawano/gnuplot/plot1-e.html#5.2

Kirtis Bakalarczyk
March 30, 2010

It looks like it was done using GLE.

http://glx.sourceforge.net/examples/2dplots/index.html

zach cp
March 30, 2010

http://zoonek2.free.fr/UNIX/48_R/04.html

try the R progmanning language. it has many plot features. if you are comfortable with matlab R shouldn’t be a big stretch

Jef Spaleta
March 30, 2010

matplotlib can do that easily.

There is an example of a shared x-axis plots in the two_scales.py example file provided in matplotlib docs in Fedora.

-jef

punchagan
March 30, 2010

This example is something similar to what you wish to do.

http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html

Troels Kofoed Jacobsen
March 30, 2010

matplotlib has a nice gallery at: http://matplotlib.sourceforge.net/gallery.html
Just click an image to get the code.

This code should pretty much solve your problem:
import numpy as np
import matplotlib.pyplot as pl

x, y1, y2 = np.loadtxt(‘test.dat’, unpack=True)
pl.plot(x, y1, ‘-o’, label=’A 280 nm’)
pl.plot(x, y2, ‘-s’, label=’Enzyme activity’)
pl.legend(loc=’upper center’)
pl.ylabel(‘$A_{280}$ [nm]‘)
pl.text(8, 1, ’1′)
pl.text(10, 0.9, ’2′)
pl.text(40, 0.8, ’3′)
pl.show()

kd
March 30, 2010

Thank you all for the reply :)
Now I am going to try the methods told by you.

Aanjhan
March 30, 2010

GNuPlot can do that with less than 10 lines of code :)
http://t16web.lanl.gov/Kawano/gnuplot/gallery/index-e.html

Ping me if you need help.

Knight
March 31, 2010

Try xmgrace.

Srivatsa
March 31, 2010

You can use “qtiplot” and use “double y” plot option.

Stefan
March 31, 2010

+1 for R: it reads you text file and you can do alto multiple plots with lattice

http://www.r-project.org

Aanjhan
March 31, 2010

Since everybody pointed at some code, time to show gnuplot power

Reference: http://t16web.lanl.gov/Kawano/gnuplot/plot1-e.html#5.2

The below 4 lines will get you the two axes. Cosmetic changes can be done to make the graph look best.

gnuplot> set xrange [0:2*pi]
gnuplot> set yrange [-1:1]
gnuplot> set y2range [0:1]
gnuplot> plot sin(x) axis x1y1, \
sin(x)**2 axis x1y2

rod
April 2, 2010

that’s a GLE graph.

Kanti
April 2, 2010

I would recommend RRDTool http://oss.oetiker.ch/rrdtool/.
It has bindings for a lot of languages.

good luck

Leave a comment

Search

Archives

Categories