Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colouring text background and labels #30

Open
gkafk opened this issue Aug 13, 2021 · 2 comments
Open

Colouring text background and labels #30

gkafk opened this issue Aug 13, 2021 · 2 comments

Comments

@gkafk
Copy link

gkafk commented Aug 13, 2021

Hi,

Is there any way of colouring the background of text region?
image

A text_box_blanking but with colour or transparency?

image

Also, is there any way of making contour lines cut around label?
image

like that?

image

thanks
George

@iainrussell
Copy link
Member

Hi George,

Good questions! To go beyond the simple white background that you get with text_box_blanking='on' you need to use the Annotation View, described a bit here: https://confluence.ecmwf.int/display/METV/Layout+in+Metview

Here is some Python code that uses it the way you want:

text = mv.mtext(
    text_lines          = ["Hello world", "How are you?"],
    text_colour         = "black",
    text_font_size      = 0.5,
    text_mode           = "positional",
    text_justification  = "left"
    )

gview = mv.geoview()

geo_page = mv.plot_page(view = gview)

annotation_view = mv.annotationview(
    #subpage_background_colour = "peach"
    subpage_background_colour = "RGBA(1, 0.5, 0.5, 0.5)"
    )

text_page = mv.plot_page(
    top    = 40, # % of main page from top-left
    bottom = 50,
    left   = 30,
    right  = 55,
    view   = annotation_view
    )

dw = mv.plot_superpage(pages = [geo_page,text_page])

mv.plot(dw[0], data, dw[1], text)

image

Unfortunately we do not support the gaps in isolines required for your second question, but blanking of labels is on, as long as you don't turn off contour_label_blanking.
image

I hope this helps a little!

Iain

@gkafk
Copy link
Author

gkafk commented Aug 18, 2021

Thanks Iain.

I will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants