Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92a93d6

Browse files
authored
Merge pull request #10126 from anntzer/axisartist-examples
Move axisartist examples to their folder.
2 parents e71d28b + 587b553 commit 92a93d6

19 files changed

Lines changed: 119 additions & 162 deletions

examples/axes_grid1/simple_axisline4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77
import matplotlib.pyplot as plt
88
from mpl_toolkits.axes_grid1 import host_subplot
9-
import mpl_toolkits.axisartist as AA
109
import numpy as np
1110

1211
ax = host_subplot(111)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
==================
3+
Demo Parasite Axes
4+
==================
5+
6+
"""
7+
from mpl_toolkits.axisartist.parasite_axes import HostAxes, ParasiteAxes
8+
import matplotlib.pyplot as plt
9+
10+
11+
fig = plt.figure(1)
12+
13+
host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8])
14+
par1 = ParasiteAxes(host, sharex=host)
15+
par2 = ParasiteAxes(host, sharex=host)
16+
host.parasites.append(par1)
17+
host.parasites.append(par2)
18+
19+
host.set_ylabel("Density")
20+
host.set_xlabel("Distance")
21+
22+
host.axis["right"].set_visible(False)
23+
par1.axis["right"].set_visible(True)
24+
par1.set_ylabel("Temperature")
25+
26+
par1.axis["right"].major_ticklabels.set_visible(True)
27+
par1.axis["right"].label.set_visible(True)
28+
29+
par2.set_ylabel("Velocity")
30+
offset = (60, 0)
31+
new_axisline = par2._grid_helper.new_fixed_axis
32+
par2.axis["right2"] = new_axisline(loc="right", axes=par2, offset=offset)
33+
34+
fig.add_axes(host)
35+
36+
host.set_xlim(0, 2)
37+
host.set_ylim(0, 2)
38+
39+
host.set_xlabel("Distance")
40+
host.set_ylabel("Density")
41+
par1.set_ylabel("Temperature")
42+
43+
p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
44+
p2, = par1.plot([0, 1, 2], [0, 3, 2], label="Temperature")
45+
p3, = par2.plot([0, 1, 2], [50, 30, 15], label="Velocity")
46+
47+
par1.set_ylim(0, 4)
48+
par2.set_ylim(1, 65)
49+
50+
host.legend()
51+
52+
host.axis["left"].label.set_color(p1.get_color())
53+
par1.axis["right"].label.set_color(p2.get_color())
54+
par2.axis["right2"].label.set_color(p3.get_color())
55+
56+
plt.show()
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)