@@ -367,7 +367,8 @@ def my_plotter(ax, data1, data2, param_dict):
367
367
#
368
368
# Each Axes has two (or three) `~.axis.Axis` objects representing the x- and
369
369
# y-axis. These control the *scale* of the Axis, the tick *locators* and the
370
- # tick *formatters*.
370
+ # tick *formatters*. Additional Axes can be attached to display further Axis
371
+ # objects.
371
372
#
372
373
# Scales
373
374
# ------
@@ -449,6 +450,34 @@ def my_plotter(ax, data1, data2, param_dict):
449
450
# numbers or dates. If you pass 1000 strings, Matplotlib will think you
450
451
# meant 1000 categories and will add 1000 ticks to your plot!
451
452
#
453
+ #
454
+ # Additional Axis objects
455
+ # ------------------------
456
+ #
457
+ # Plotting data of different magnitude in one chart may require
458
+ # an additional y-axis. Such an Axis can be created by using
459
+ # `~.Axes.twinx` to add a new Axes with an invisible x-axis and a y-axis
460
+ # positioned at the right (analogously for `~.Axes.twiny`). See
461
+ # :doc:`/gallery/subplots_axes_and_figures/two_scales` for another example.
462
+ #
463
+ # Similarly, you can add a `~.Axes.secondary_xaxis` or
464
+ # `~.Axes.secondary_yaxis` having a different scale than the main Axis to
465
+ # represent the data in different scales or units. See
466
+ # :doc:`/gallery/subplots_axes_and_figures/secondary_axis` for further
467
+ # examples.
468
+
469
+ fig , (ax1 , ax3 ) = plt .subplots (1 , 2 , figsize = (8 , 2.7 ), constrained_layout = True )
470
+ l1 , = ax1 .plot (t , s )
471
+ ax2 = ax1 .twinx ()
472
+ l2 , = ax2 .plot (t , range (len (t )), 'C1' )
473
+ ax2 .legend ([l1 , l2 ], ['Sine (left)' , 'Straight (right)' ])
474
+
475
+ ax3 .plot (t , s )
476
+ ax3 .set_xlabel ('Angle [°]' )
477
+ ax4 = ax3 .secondary_xaxis ('top' , functions = (np .rad2deg , np .deg2rad ))
478
+ ax4 .set_xlabel ('Angle [rad]' )
479
+
480
+ ##############################################################################
452
481
# Color mapped data
453
482
# =================
454
483
#
0 commit comments