Skip to content

Commit

Permalink
Merge pull request #22 from m3g/adjust_latex_font
Browse files Browse the repository at this point in the history
Adjust latex font
  • Loading branch information
lmiq authored Dec 20, 2024
2 parents b0356cd + a229668 commit de524fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/plotting_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ julia> plot(MolSimStyle, x, y)
All other normal parameters of `Plots` function can be used to change the plot labels,
titles, legends, font sizes, etc.

!!! tip
In v1.21.2, if if setting `fontfamily="Serif"`, LaTeXStrings will be converted to `\mathsf`
to match the overall plot fonts. This behavior can be disabled with `adjust_latex_font=false`.

## Available plotting functions

The `Plots` functions that are overloaded are:
Expand Down
14 changes: 12 additions & 2 deletions ext/MolSimStyle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ const MolSimStyle_parameters = Dict{Symbol,Any}(
:grid => false,
:xlabel => "x",
:ylabel => "y",
:adjust_latex_font => true,
)

#
# overwrite default parameters or add parameters if other kargs where passed
#
function _kargs(parameters = MolSimStyle_parameters; kargs)
custom_parameters = copy(parameters)
function _kargs(default=MolSimStyle_parameters; kargs)
custom_parameters = deepcopy(default)
for karg in keys(kargs)
custom_parameters[karg] = kargs[karg]
end
fontfamily = custom_parameters[:fontfamily]
if fontfamily in ("Sans Serif", "Serif", "Arial") && custom_parameters[:adjust_latex_font]
for key in keys(custom_parameters)
value = custom_parameters[key]
if value isa LaTeXString
custom_parameters[key] = LaTeXStrings.latexstring("\\mathsf{$(String(value)[2:end-1])}")
end
end
end
return custom_parameters
end

Expand Down
2 changes: 2 additions & 0 deletions ext/SecondaryStructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function MolSimToolkit.ss_heatmap(
:clims => (0.5,10.5),
:xlabel => "frame",
:ylabel => "residue",
:fontfamily => "Computer Modern",
:adjust_latex_font => true,
)
plt = Plots.heatmap(MolSimStyle, scalex*(1:size(ssmap,2)), 1:size(ssmap,1), ssmap; _kargs(default; kargs)...)
return plt
Expand Down

0 comments on commit de524fc

Please sign in to comment.