In [2]:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 11)
y = x ** 2
%matplotlib inline
In [3]:
fig1=plt.figure()
axes1=fig1.add_axes([0.1,0.1,0.8,0.8])
axes1.plot(x,y,"r")
axes1.set_xlabel("my x label")
axes1.set_ylabel("my y label")
axes1.set_title("Mydata")
Out[3]:
In [21]:
fig1=plt.figure()
axes1=fig1.add_axes([0.1,0.1,0.8,0.8])
axes2=fig1.add_axes([0.2,0.4,0.4,0.3])
axes1.plot(x,y,"r")
axes2.plot(y,x,"b")
axes1.set_xlabel("my x label")
axes1.set_ylabel("my y label")
axes1.set_title("Mydata")
axes2.set_xlabel("my inner x label")
axes2.set_ylabel("my inner y label")
axes2.set_title("My inner data")
Out[21]:
In [22]:
# Use similar to plt.figure() except use tuple unpacking to grab fig and axes
fig, axes = plt.subplots()
# Now use the axes object to add stuff to plot
axes.plot(x, y, 'r')
axes.set_xlabel('x')
axes.set_ylabel('y')
axes.set_title('title');
In [23]:
fig, axes = plt.subplots(nrows=1, ncols=2)
In [27]:
Out[27]:
No comments:
Post a Comment