Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple overlapping plots with independent scaling in Matplotlib

I currently have code that calls matplotlib.pylab.plot multiple times to display multiple sets of data on the same screen, and Matplotlib scales each to the global min and max, considering all plots. Is there a way to ask it to scale each plot independently, to the min and max of that particular plot?

like image 239
user3562 Avatar asked Mar 15 '09 07:03

user3562


People also ask

How do I stop Matplotlib overlapping?

Use legend() method to avoid overlapping of labels and autopct. To display the figure, use show() method.


1 Answers

There's no direct support for this, but here's some code from a mailing list posting that illlustrates two independent vertical axes:

x=arange(10)
y1=sin(x)
y2=10*cos(x)

rect=[0.1,0.1,0.8,0.8]
a1=axes(rect)
a1.yaxis.tick_left()
plot(x,y1)
ylabel('axis 1')
xlabel('x')

a2=axes(rect,frameon=False)
a2.yaxis.tick_right()
plot(x,y2)
a2.yaxis.set_label_position('right')
ylabel('axis 2')
a2.set_xticks([])
like image 200
Jouni K. Seppänen Avatar answered Sep 21 '22 19:09

Jouni K. Seppänen