@@ -575,17 +575,19 @@ def custom_box_style(x0, y0, width, height, mutation_size):
575
575
# %%
576
576
# Another commonly used `.Transform` instance is ``Axes.transData``. This
577
577
# transform is the coordinate system of the data plotted in the axes. In this
578
- # example, it is used to draw an arrow from a point in *ax1* to text in *ax2*,
579
- # where the point and text are positioned relative to the coordinates of *ax1*
580
- # and *ax2* respectively:
578
+ # example, it is used to draw an arrow between related data points in two
579
+ # Axes. We have passed an empty text because in this case, the annotation
580
+ # connects data points.
581
581
582
- fig , ( ax1 , ax2 ) = plt . subplots ( nrows = 1 , ncols = 2 , figsize = ( 6 , 3 ) )
582
+ x = np . linspace ( - 1 , 1 )
583
583
584
- ax1 .annotate ("Test1" , xy = (0.5 , 0.5 ), xycoords = "axes fraction" )
585
- ax2 .annotate ("Test2" ,
586
- xy = (0.5 , 0.5 ), xycoords = ax1 .transData ,
587
- xytext = (0.5 , 0.5 ), textcoords = ax2 .transData ,
588
- arrowprops = dict (arrowstyle = "->" ))
584
+ fig , (ax1 , ax2 ) = plt .subplots (nrows = 1 , ncols = 2 , figsize = (6 , 3 ))
585
+ ax1 .plot (x , - x ** 3 )
586
+ ax2 .plot (x , - 3 * x ** 2 )
587
+ ax2 .annotate ("" ,
588
+ xy = (0 , 0 ), xycoords = ax1 .transData ,
589
+ xytext = (0 , 0 ), textcoords = ax2 .transData ,
590
+ arrowprops = dict (arrowstyle = "<->" ))
589
591
590
592
# %%
591
593
# .. _artist_annotation_coord:
0 commit comments