[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #TKX-201706]: tinkering with coloured hodograph
- Subject: [python #TKX-201706]: tinkering with coloured hodograph
- Date: Tue, 27 Feb 2018 13:24:25 -0700
HP,
If you want to use a colormap and a norm with plot_colormapped, you need to
pass them in as the "norm" and "cmap" keyword arguments, respectively:
h = Hodograph(ax, component_range=60)
h.add_grid(increment=10)
norm, cmap=ctables.registry.get_with_range('test',0,60)
h.plot_colormapped(u,v,np.hypot(u,v), norm=norm, cmap=cmap)
I have opened an issue reminding us to add something like this to the examples:
https://github.com/Unidata/MetPy/issues/752
Thanks for the report!
Ryan
> ---------- Forwarded message ----------
> From: HansPeter Roesli <address@hidden>
> Date: Tue, Feb 27, 2018 at 6:05 AM
> Subject: tinkering with coloured hodograph
> To: address@hidden
>
>
> Hi -
>
> I would like to draw a hodograph with more contrast than given by the
> default colours. So, I am going like
>
> h = Hodograph(ax, component_range=60)
> h.add_grid(increment=10)
> norm,cmap=ctables.registry.get_with_range('test',0,60)
> h.plot_colormapped(u,v,np.hypot(u,v),bounds=norm,colors=cmap)
>
> While plot_colormapped without bounds and colors works as expected, the
> above code ends in an error message
>
> ...
> File
> "C:\Users\hproe_000\AppData\Roaming\Python\Python36\site-packages\matplotlib\colors.py",
> line 793, in __init__
> N = len(colors)
>
> TypeError: object of type 'ListedColormap' has no len()
>
> Any idea what I am doing wrong here?
>
> cheers, HP
>
Ticket Details
===================
Ticket ID: TKX-201706
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.