@@ -692,26 +692,40 @@ def boxes_to_svg(self, elements=None, **options) -> str:
692692 svg_body = format_fn (self , elements , data = data , ** options )
693693 return svg_body
694694
695- def create_axes (self , elements , graphics_options , xmin , xmax , ymin , ymax ):
695+ def create_axes (self , elements , graphics_options , xmin , xmax , ymin , ymax ) -> tuple :
696+
697+ # Note that Asymptote has special commands for drawing axes, like "xaxis"
698+ # "yaxis", "xtick" "labelx", "labely". Entend our language
699+ # here and use those in render-like routines.
700+
696701 use_log_for_y_axis = graphics_options .get ("System`LogPlot" , False )
697- axes = graphics_options .get ("System`Axes" )
698- if axes is SymbolTrue :
702+ axes_option = graphics_options .get ("System`Axes" )
703+
704+ if axes_option is SymbolTrue :
699705 axes = (True , True )
700- elif axes .has_form ("List" , 2 ):
701- axes = (axes .elements [0 ] is SymbolTrue , axes .elements [1 ] is SymbolTrue )
706+ elif axes_option .has_form ("List" , 2 ):
707+ axes = (
708+ axes_option .elements [0 ] is SymbolTrue ,
709+ axes_option .elements [1 ] is SymbolTrue ,
710+ )
702711 else :
703712 axes = (False , False )
704- ticks_style = graphics_options .get ("System`TicksStyle" )
705- axes_style = graphics_options .get ("System`AxesStyle" )
713+
714+ # The Style option pushes its setting down into graphics components
715+ # like ticks, axes, and labels.
716+ ticks_style_option = graphics_options .get ("System`TicksStyle" )
717+ axes_style_option = graphics_options .get ("System`AxesStyle" )
706718 label_style = graphics_options .get ("System`LabelStyle" )
707- if ticks_style .has_form ("List" , 2 ):
708- ticks_style = ticks_style .elements
719+
720+ if ticks_style_option .has_form ("List" , 2 ):
721+ ticks_style = ticks_style_option .elements
709722 else :
710- ticks_style = [ticks_style ] * 2
711- if axes_style .has_form ("List" , 2 ):
712- axes_style = axes_style .elements
723+ ticks_style = [ticks_style_option ] * 2
724+
725+ if axes_style_option .has_form ("List" , 2 ):
726+ axes_style = axes_style_option .elements
713727 else :
714- axes_style = [axes_style ] * 2
728+ axes_style = [axes_style_option ] * 2
715729
716730 ticks_style = [elements .create_style (s ) for s in ticks_style ]
717731 axes_style = [elements .create_style (s ) for s in axes_style ]
@@ -723,12 +737,16 @@ def add_element(element):
723737 element .is_completely_visible = True
724738 elements .elements .append (element )
725739
740+ # Units seem to be in point size units
741+
726742 ticks_x , ticks_x_small , origin_x = self .axis_ticks (xmin , xmax )
727743 ticks_y , ticks_y_small , origin_y = self .axis_ticks (ymin , ymax )
728744
729745 axes_extra = 6
746+
730747 tick_small_size = 3
731748 tick_large_size = 5
749+
732750 tick_label_d = 2
733751
734752 ticks_x_int = all (floor (x ) == x for x in ticks_x )
@@ -791,8 +809,10 @@ def add_element(element):
791809 )
792810 )
793811 ticks_lines = []
812+
794813 tick_label_style = ticks_style [index ].clone ()
795814 tick_label_style .extend (label_style )
815+
796816 for x in ticks :
797817 ticks_lines .append (
798818 [
@@ -816,6 +836,7 @@ def add_element(element):
816836 content = String (
817837 "%g" % tick_value
818838 ) # fix e.g. 0.6000000000000001
839+
819840 add_element (
820841 InsetBox (
821842 elements ,
@@ -839,31 +860,32 @@ def add_element(element):
839860 add_element (LineBox (elements , axes_style [0 ], lines = ticks_lines ))
840861 return axes
841862
842- """if axes[1]:
843- add_element(LineBox(elements, axes_style[1], lines=[[Coords(elements, pos=(origin_x,ymin), d=(0,-axes_extra)),
844- Coords(elements, pos=(origin_x,ymax), d=(0,axes_extra))]]))
845- ticks = []
846- tick_label_style = ticks_style[1].clone()
847- tick_label_style.extend(label_style)
848- for k in range(start_k_y, start_k_y+steps_y+1):
849- if k != origin_k_y:
850- y = k * step_y
851- if y > ymax:
852- break
853- pos = (origin_x,y)
854- ticks.append([Coords(elements, pos=pos),
855- Coords(elements, pos=pos, d=(tick_large_size,0))])
856- add_element(InsetBox(elements, tick_label_style, content=Real(y), pos=Coords(elements, pos=pos,
857- d=(-tick_label_d,0)), opos=(1,0)))
858- for k in range(start_k_y_small, start_k_y_small+steps_y_small+1):
859- if k % sub_y != 0:
860- y = k * step_y_small
861- if y > ymax:
862- break
863- pos = (origin_x,y)
864- ticks.append([Coords(elements, pos=pos),
865- Coords(elements, pos=pos, d=(tick_small_size,0))])
866- add_element(LineBox(elements, axes_style[1], lines=ticks))"""
863+ # Old code?
864+ # if axes[1]:
865+ # add_element(LineBox(elements, axes_style[1], lines=[[Coords(elements, pos=(origin_x,ymin), d=(0,-axes_extra)),
866+ # Coords(elements, pos=(origin_x,ymax), d=(0,axes_extra))]]))
867+ # ticks = []
868+ # tick_label_style = ticks_style[1].clone()
869+ # tick_label_style.extend(label_style)
870+ # for k in range(start_k_y, start_k_y+steps_y+1):
871+ # if k != origin_k_y:
872+ # y = k * step_y
873+ # if y > ymax:
874+ # break
875+ # pos = (origin_x,y)
876+ # ticks.append([Coords(elements, pos=pos),
877+ # Coords(elements, pos=pos, d=(tick_large_size,0))])
878+ # add_element(InsetBox(elements, tick_label_style, content=Real(y), pos=Coords(elements, pos=pos,
879+ # d=(-tick_label_d,0)), opos=(1,0)))
880+ # for k in range(start_k_y_small, start_k_y_small+steps_y_small+1):
881+ # if k % sub_y != 0:
882+ # y = k * step_y_small
883+ # if y > ymax:
884+ # break
885+ # pos = (origin_x,y)
886+ # ticks.append([Coords(elements, pos=pos),
887+ # Coords(elements, pos=pos, d=(tick_small_size,0))])
888+ # add_element(LineBox(elements, axes_style[1], lines=ticks))
867889
868890
869891class FilledCurveBox (_GraphicsElementBox ):
0 commit comments