ecmwf / magics

Plotting package to visualise meteorological data in GRIB, NetCDF, BUFR and ODB format.
Apache License 2.0
56 stars 15 forks source link

html codes not plotted for PS and EPS output #108

Open pdando opened 6 months ago

pdando commented 6 months ago

What happened?

Magics does not plot html codes correctly in title when PS and EPS output is chosen.

What are the steps to reproduce the bug?

This is reproduced using the following Python script (based on Axis example 2):

#importing Magics module
from Magics.macro import *

ref = 'axis2'

#Setting of the output file name
output = output(
                output_formats = ['png','ps','eps','pdf'], 
                output_name_first_page_number = "off",
                output_name = ref
               )

#Setting the cartesian view
projection = mmap(
                  subpage_y_position= 2., 
                  subpage_map_projection = 'cartesian',
                  subpage_x_axis_type = 'date',
                  subpage_y_axis_type = 'regular',
                  subpage_x_date_min = "2012-04-10",
                  subpage_x_date_max = "2012-04-28",
                  subpage_y_min = -20.,
                  subpage_y_max = 20.
                 )

#Vertical axis
vertical = maxis(
                 axis_orientation = "vertical",
                 axis_grid =  "on",
                 axis_type =  "regular",
                 axis_grid_colour = "grey",
                 axis_grid_thickness = 1,
                 axis_grid_reference_level = 0.,
                 axis_grid_reference_line_style='solid',
                 axis_grid_reference_thickness=2,
                 axis_grid_line_style = "dot"
                )

#Horizontal axis
horizontal = maxis(
                   axis_orientation = "horizontal",
                   axis_type =  "date",
                   axis_grid =  "on",
                   axis_days_label_height =  0.4,
                   axis_months_label_height =  0.4,
                   axis_years_label_height =  0.4,
                   axis_grid_colour = "grey",
                   axis_grid_thickness = 1,
                   axis_grid_line_style = "dot"
                  )

lines =["Using time series...for units μm - should be  micrometres with a Greek letter mu"]

title = mtext({
               "text_lines" : lines,
               "text_html" : "true",
               "text_justification": "left",
               "text_font_size": 0.75,
               "text_colour" : "charcoal"
             })

#To the plot
plot(output, projection, vertical, horizontal, title)

Run as:

python3 axis2.py

The title should read:

"Using time series...for units µm - should be micrometres with a Greek letter mu"

This is correct for PNG and PDF output but the "µ" is not printed in the PS or EPS output.

Also fails to print in PS/EPS if tried with HTML decimal (μ), HTML hex (μ;, or as "\u03BC).

See also plots attached to linked ticket MAGP-1343.

Version

4.14.1 and older

Platform (OS and architecture)

Linux ac6-200.bullx 4.18.0-372.52.1.el8_6.x86_64 #1 SMP Fri Mar 31 06:22:44 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF (reporting on behalf of AEMET)

sylvielamythepaut commented 6 months ago

Hi Paul, We will recommend users to consider using the PDF format, do you think they could try ? Thank you Sylvie

pdando commented 6 months ago

Hi Sylvie,

I hope retirement is treating you well ! I see you are still able to provide some Magics support in GitHub !

Of course, I can ask the user to use PDF. Unfortunately, the same user also reported the issue with the Spanish weekday names in https://github.com/ecmwf/magics/issues/109 which doesn't work with PDF !!

But, if you can solve #109 so that the Spanish (or non-english) weekday names are plotted correctly in PDF then the user should be able to use PDF for everything.

Paul