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

Clean up High/Low Plotting Function A Bit #1234

Open
MethaneRain opened this issue Nov 13, 2019 · 3 comments · May be fixed by #1237 or #3110
Open

Clean up High/Low Plotting Function A Bit #1234

MethaneRain opened this issue Nov 13, 2019 · 3 comments · May be fixed by #1237 or #3110
Labels
Area: Examples Affects examples Type: Enhancement Enhancement to existing functionality

Comments

@MethaneRain
Copy link

MethaneRain commented Nov 13, 2019

The High Low function introduced in the MSLP 1000-500mb Thickness plotting example is a wonderful touch to Python graphics. I thought maybe adding a black outline to the text would help it pop a bit more.

ex:

With matplotlib.patheffects and outline_effect = [patheffects.withStroke(linewidth=2.5, foreground='black')]

I also added an ax argument to the code so it could be imported as an external library and plot to the current axes.


def plot_maxmin_points(ax, lon, lat, data, extrema, nsize, symbol, color='k',
                       plotValue=True, transform=None):
       import numpy as np
       from matplotlib import patheffects
       from scipy.ndimage.filters import maximum_filter, minimum_filter
       outline_effect = [patheffects.withStroke(linewidth=2.5, foreground='black')]
       
       mxy, mxx = np.where(data_ext == data)
       #print(mxy,mxx)
    
       for i in range(len(mxy)):
          A = ax.text(lon[mxy[i], mxx[i]], lat[mxy[i], mxx[i]], symbol, color=color, size=24,
                    clip_on=True, horizontalalignment='center', verticalalignment='center',
                    transform=transform)
          A.set_path_effects(outline_effect)
          B = ax.text(lon[mxy[i], mxx[i]], lat[mxy[i], mxx[i]]-0.66,
                    str(np.int(data[mxy[i], mxx[i]])),
                    color=color, size=12, clip_on=True, fontweight='bold',
                    horizontalalignment='center', verticalalignment='top', transform=transform)
          B.set_path_effects(outline_effect)

Since adding an outline pushes the pressures too close to the symbol I gave it some space, there's probably a more accepted way but this worked for me in my case.

lon[mxy[i], mxx[i]], lat[mxy[i], mxx[i]]-0.66

Thought I would pass my 2 cents on!

Sample Image:

Source code for my HiLo

@MethaneRain MethaneRain added the Type: Feature New functionality label Nov 13, 2019
@dopplershift dopplershift added Area: Examples Affects examples Type: Enhancement Enhancement to existing functionality and removed Type: Feature New functionality labels Nov 13, 2019
@dopplershift
Copy link
Member

I think this seems like some nice improvements. I'd be interested in seeing a PR go in to update the example.

We could also look at incorporating the extrema-finding and the plotting as functions in MetPy.

@MethaneRain MethaneRain linked a pull request Nov 17, 2019 that will close this issue
3 tasks
@MethaneRain
Copy link
Author

We could also look at incorporating the extrema-finding and the plotting as functions in MetPy.

I figured it would be good place to have it since it seems to work and adds a nice graphic to surface and upper mb plots

@eliteuser26
Copy link
Contributor

I would make a suggestion for the Hi/Low feature. The red colour does show well with the black highlight but it is hard to read the dark blue colour and black highlight. I would suggest a lighter blue colour with the black highlight to make easier to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Examples Affects examples Type: Enhancement Enhancement to existing functionality
Projects
None yet
3 participants