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

mp changes to ds_plots.py #1

Merged
merged 2 commits into from
Nov 28, 2018
Merged

mp changes to ds_plots.py #1

merged 2 commits into from
Nov 28, 2018

Conversation

mp586
Copy link
Owner

@mp586 mp586 commented Nov 26, 2018

Changes to ds_plots.py to allow lon, lat and mapdata in function mmap() to not be numpy arrays.
Changed pcolormesh to contourf because pcolormesh didn't work for me -- this might be Python environment dependent...

Also started creating a short script (plotting_script.py) to call plotting functions from ds_tools

@timothyas timothyas self-assigned this Nov 28, 2018
@timothyas
Copy link
Collaborator

Actually, I'm not sure how I got around this before. I just tried using pcolormesh and ran into the same issue. It seems to be a problem with matplotlib version 3.0.0 because they removed the attribute _hold. This was only fixed in cartopy 20 days ago via QuLogic/cartopy@b24ec66 (see the issue: SciTools/cartopy#1120). The fix hasn't been updated in their anaconda distribution yet.

However, matplotlib added this back in for cartopy in 3.0.1 so you can use pcolormesh after updating to this version. E.g. in an anaconda environment

conda update matplotlib

Will get you using pcolormesh again. However, I added the option use_pcolor=False so that contourf is used by default but pcolormesh can be used by setting to true. See updated lines:

ACDC/tools/ds_plots.py

Lines 110 to 126 in 0a17eba

def mmap(mapdata,lat,lon,title=None,cb_ttl=None,cmap=None,clim=None,
filepath=None,show=None,sigmask=None,p=None,
do_zonal=None,newfig=True,
outside_color = None, outside_val=None,
use_pcolor=False):
# Make a map (robinson projection) of mapdata over lat/lon
# Inputs
# mapdata : 2D field to be plotted
# lat : latitude coordinates
# lon : longitude coordinates
#
# Optional inputs
# title : map title
# cb_ttl : colorbar title
# cmap : special colormap
# clim : colorbar limits, as a 2 element array
# use_pcolor: default is to use contourf. Set True for pcolormesh

ACDC/tools/ds_plots.py

Lines 150 to 155 in 0a17eba

# Make the plot
# Default: contourf
if not use_pcolor:
cs = plt.contourf(cyclic_lons,lat,cyclic_data,transform=ccrs.PlateCarree())
else:
cs = plt.pcolormesh(cyclic_lons,lat,cyclic_data,transform=ccrs.PlateCarree())

@timothyas timothyas merged commit 0a17eba into master Nov 28, 2018
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

Successfully merging this pull request may close these issues.

2 participants