Skip to content

Commit

Permalink
Added row gap scale factor for curve legends
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsignorelli committed Nov 14, 2024
1 parent 62d2f25 commit 9c14162
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bmad/doc/subroutines.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ \subsection{Quick Plot Drawing Routines}
\index[routine]{qp_draw_curve_legend}
\label{r:qp.draw.curve.legend}
\item[\protect\parbox{6in}{qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, \\
\hspace*{1in} symbol, text, text_offset, draw_line, draw_symbol, draw_text) }] \Newline
\hspace*{1in} symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text) }] \Newline
Routine to draw a legend with each line in the legend having
a line, a symbol, some text.

Expand Down
43 changes: 22 additions & 21 deletions sim_utils/plot/quick_plot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2897,41 +2897,42 @@ end subroutine qp_draw_text_legend
!-----------------------------------------------------------------------
!+
! Subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length,
! symbol, text, text_offset, draw_line, draw_symbol, draw_text)
! symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text)
!
! Subroutine to draw a legend with each line in the legend having
! a line, a symbol, some text.
!
! Input:
! x_origin -- Real(rp), optional: x-postion of start of the first line.
! y_origin -- Real(rp), optional: y-postion of start of the first line.
! units -- Character(*), optional: Units of x_origin, y_origin.
! Default is: 'DATA/GRAPH/LB'
! See quick_plot writeup for more details.
! line(:) -- qp_line_struct, optional: Array of lines.
! Set line(i)%width < 0 to suppress drawing of the i^th line
! line_length -- Real(rp), optional: Length of the line in points. Default is 72 pts (~ 1 inch).
! symbol(:) -- qp_symbol_struct, optional: Array of symbols.
! Set symbol(i)%type < 0 to suppress drawing of the i^th symbol.
! text(:) -- Character(*), optional: Array of text lines.
! text_offset -- Real(rp), optional: Horizontal offset in points between the line and the text.
! Default is 10 pt.
! draw_line -- Logical, optional: Draw lines? Default is True if line arg is present.
! Line style set by the LEGEND line style. See qp_set_line_attrib.
! draw_symbol -- Logical, optional: Draw symbols? Default is True if symbol arg is present.
! draw_text -- Logical, optional: Draw text? Default is True if text arg is present.
! x_origin -- Real(rp), optional: x-postion of start of the first line.
! y_origin -- Real(rp), optional: y-postion of start of the first line.
! units -- Character(*), optional: Units of x_origin, y_origin.
! Default is: 'DATA/GRAPH/LB'
! See quick_plot writeup for more details.
! line(:) -- qp_line_struct, optional: Array of lines.
! Set line(i)%width < 0 to suppress drawing of the i^th line
! line_length -- Real(rp), optional: Length of the line in points. Default is 72 pts (~ 1 inch).
! symbol(:) -- qp_symbol_struct, optional: Array of symbols.
! Set symbol(i)%type < 0 to suppress drawing of the i^th symbol.
! text(:) -- Character(*), optional: Array of text lines.
! text_offset -- Real(rp), optional: Horizontal offset in points between the line and the text.
! Default is 10 pt.
! row_gap_scale -- Real(rp), optional: Scale factor for gap size between entries in a legend. Default is 1.
! draw_line -- Logical, optional: Draw lines? Default is True if line arg is present.
! Line style set by the LEGEND line style. See qp_set_line_attrib.
! draw_symbol -- Logical, optional: Draw symbols? Default is True if symbol arg is present.
! draw_text -- Logical, optional: Draw text? Default is True if text arg is present.
!-

subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, &
symbol, text, text_offset, draw_line, draw_symbol, draw_text)
symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text)

implicit none

type (qp_line_struct), optional :: line(:)
type (qp_symbol_struct), optional :: symbol(:)

real(rp) x_origin, y_origin
real(rp), optional :: line_length, text_offset
real(rp), optional :: line_length, text_offset, row_gap_scale
real(rp) height, xc, yc, yc2, line_len, dummy, text_off

integer i, n_rows
Expand All @@ -2948,7 +2949,7 @@ subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, &

call qp_set_text_attrib ('LEGEND')
call qp_set_line_attrib ('LEGEND')
height = qp_text_height_to_inches(qp_com%this_text%height)
height = real_option(1.0_rp, row_gap_scale)*qp_text_height_to_inches(qp_com%this_text%height)

call qp_to_inch_abs (x_origin, y_origin, xc, yc, units)

Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_init_plotting.f90
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ function old_style_title_syntax(iu) result (is_old_style)
grph%type = graph%type
grph%x_axis_scale_factor = graph%x_axis_scale_factor
grph%symbol_size_scale = graph%symbol_size_scale
grph%curve_legend_row_gap_scale = graph%curve_legend_row_gap_scale
grph%text_legend_origin = graph%text_legend_origin
grph%curve_legend_origin = graph%curve_legend_origin
grph%box = graph%box
Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_input_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ module tao_input_struct
integer :: n_curve = -1
real(rp) :: x_axis_scale_factor = 1
real(rp) :: symbol_size_scale = 0
real(rp) :: curve_legend_row_gap_scale = 1
real(rp) :: floor_plan_rotation = real_garbage$ ! deprecated. Use g%floor_plan%...
real(rp) :: floor_plan_orbit_scale = -1 ! deprecated. Use g%floor_plan%...
logical :: floor_plan_flip_label_side = .false. ! deprecated. Use g%floor_plan%...
Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_pipe_cmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5413,6 +5413,7 @@ subroutine tao_pipe_cmd (input_str)
nl=incr(nl); write (li(nl), amt) 'why_invalid;STR;F;', trim(g%why_invalid)
nl=incr(nl); write (li(nl), rmt) 'x_axis_scale_factor;REAL;T;', g%x_axis_scale_factor
nl=incr(nl); write (li(nl), rmt) 'symbol_size_scale;REAL;T;', g%symbol_size_scale
nl=incr(nl); write (li(nl), rmt) 'curve_legend_row_gap_scale;REAL;T;', g%curve_legend_row_gap_scale
nl=incr(nl); write (li(nl), jmt) g%ix_universe, '^ix_branch;INUM;T;', g%ix_branch
nl=incr(nl); write (li(nl), imt) 'ix_universe;INUM;T;', g%ix_universe
nl=incr(nl); write (li(nl), lmt) 'clip;LOGIC;T;', g%clip
Expand Down
2 changes: 1 addition & 1 deletion tao/code/tao_plot_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ subroutine tao_draw_graph_axes (plot, graph)
if (graph%draw_curve_legend .and. nc > 1) then
call qp_draw_curve_legend (graph%curve_legend_origin%x, graph%curve_legend_origin%y, &
graph%curve_legend_origin%units, line, s%plot_page%curve_legend_line_len, &
symbol, text, s%plot_page%curve_legend_text_offset)
symbol, text, s%plot_page%curve_legend_text_offset, graph%curve_legend_row_gap_scale)
endif


Expand Down
2 changes: 2 additions & 0 deletions tao/code/tao_set_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,8 @@ subroutine set_this_graph (this_graph)
call tao_set_qp_rect_struct (comp, sub_comp, this_graph%margin, value, error, u%ix_uni)
case ('name')
this_graph%name = value_str
case ('curve_legend_row_gap_scale')
call tao_set_real_value(this_graph%curve_legend_row_gap_scale, component, value, error, dflt_uni = u%ix_uni)
case ('scale_margin')
call tao_set_qp_rect_struct (comp, sub_comp, this_graph%scale_margin, value, error, u%ix_uni)
case ('symbol_size_scale')
Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_show_this.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,7 @@ subroutine tao_show_this (what, result_id, lines, nl)

nl=nl+1; write(lines(nl), rmt) 'x_axis_scale_factor = ', g%x_axis_scale_factor
nl=nl+1; write(lines(nl), rmt) 'symbol_size_scale = ', g%symbol_size_scale
nl=nl+1; write(lines(nl), rmt) 'curve_legend_row_gap_scale = ', g%curve_legend_row_gap_scale
nl=nl+1; write(lines(nl), amt) 'text_legend_origin%x,y,units = ', real_str(g%text_legend_origin%x, 3), ', ', &
real_str(g%text_legend_origin%y, 3), ', ', quote(g%text_legend_origin%units)
nl=nl+1; write(lines(nl), amt) 'curve_legend_origin%x,y,units = ', real_str(g%curve_legend_origin%x, 3), ', ', &
Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ module tao_struct
type (qp_rect_struct) :: scale_margin = qp_rect_struct() ! Margin for scaling
real(rp) :: x_axis_scale_factor = 1 ! x-axis conversion from internal to plotting units.
real(rp) :: symbol_size_scale = 0 ! Symbol size scale factor for phase_space plots.
real(rp) :: curve_legend_row_gap_scale = 1 ! Row gap scale factor for each entry in the curve legend.
integer :: box(4) = 0 ! Defines which box the plot is put in.
integer :: ix_branch = -1 ! Branch in lattice. Used when there are no associated curves.
integer :: ix_universe = -1 ! Used for lat_layout plots.
Expand Down
2 changes: 2 additions & 0 deletions tao/doc/initialization.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,7 @@ \subsection{Plot Templates}
\index{graph_index}\index{graph}\index{graph!name}\index{curve}
\index{graph!type}\index{graph!box}\index{graph!title}\index{graph!margin}
\index{graph!y2}\index{graph!n_curve}\index{graph!clip}\index{graph!component}
\index{graph!curve_legend_row_gap_scale}
\index{graph!symbol_size_scale}
\index{curve!data_type}\index{curve!data_source}
\index{curve!x_axis_units_factor}\index{curve!y_axis_units_factor}
Expand Down Expand Up @@ -2507,6 +2508,7 @@ \subsection{Plot Templates}
= <logical> ! Default = T.
graph%x_axis_scale_factor = <factor> ! Scale the x-axis by this.
graph%n_curve = <integer> ! Limit number of curves.
graph%curve_legend_row_gap_scale = <real> ! Scales the row gap width between entries in the legend.
curve(N)%name = "<string>" ! Default is "c<i>", <i> = curve num.
curve(N)%data_type = "<string>" ! EG: "orbit.x"
curve(N)%data_source = "<string>" ! Source for the data curve points
Expand Down

0 comments on commit 9c14162

Please sign in to comment.