Comments (5)
Hi @davidmnielsen! Thanks for reporting this 😄 As already mentioned per mail, a workaround is to use matplotlibs edgecolor
property via
maps = psy.plot.mapplot(file_lr,
name='area',
cmap='Blues',
maskleq=0,
stock_img=True,
lonlatbox=[-180, 180, 60, 90],
extend='max',
load=True,
projection='northpole',
xgrid=False, ygrid=False,
clabel='{desc}',title='LR',
bounds=np.arange(0,10000000000,1000000000),
datagrid=dict(color='k', linewidth=0.1),
tight=True,
post="self.plotter.plot.mappable.set_edgecolor('k')")
But I am working on it. The problem appears only for grid with 2D coordinates, such as the curvilinear grid you are using here.
from psy-maps.
Hey! It seems like I have to fix an old issue with the visualization of curvilinear grids in order to solve this problem.
The point is: Matplotlib actually visualizes your data wrong. When typing
plot.pcolormesh(x, y, data)
with data.shape == y.shape
(as it is the case for curvilinear grids), matplotlib gets rid of the last row and last column of the data
and handles the grid cell centers in y
as the cell node coordinates (see matplotlibs source code). However, as I mentioned already in the circumpolar grid example, this introduces an error in the visualization.
psyplot usually interpolates the bounds to avoid this error, but I did not yet find a good solution on how to do this with 2D coordinates. So far, I disable the interpolation with the interp_bounds
formatoption, and, if desired, one can interpolate the bounds using scipys interp2d
function (see psyplot.data.CFDecoder._infer_interval_breaks). This function however does not work with NaN
in the data and as such, it fails at the boundaries of the curvilinear grid.
Long story short: If there is no suggestion on how to get the grid cell boundaries out of the 2D coordinates, I have to disable the visualization of data grids for curvilinear data. Any idea how to solve this?
from psy-maps.
Hi!
I found a solution, or at least for the visualization outcome I was aiming for. Somehow (extensive Stack Exchange digging), I got pcolormesh
to work in Cartopy.
Thank you a lot for your time and effort to help us! :)
def circlemap():
import numpy as np
import matplotlib.path as mpath
theta = np.linspace(0, 2*np.pi, 100)
center, radius = [0.5, 0.5], 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
circle = mpath.Path(verts * radius + center)
return circle
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111,projection=ccrs.NorthPolarStereo())
ax.set_extent([-180, 180, 63, 90], crs=ccrs.PlateCarree())
ax.coastlines()
circle=circlemap()
ax.set_boundary(circle, transform=ax.transAxes)
mesh = ax.pcolormesh(lon, lat, area*factor, cmap='Blues',
transform=ccrs.PlateCarree(),
vmin=0, vmax=10000,
antialiased=True, edgecolor='k', linewidth=0.3)
plt.colorbar(mesh, orientation='horizontal', shrink=0.75,label='grid-cell area [km^2]')
plt.show()
I added a full reproducible Jupyter-Notebook to the repository: https://github.com/davidmnielsen/gridcell_area
from psy-maps.
Oh, and yes, adding the argument post="self.plotter.plot.mappable.set_edgecolor('k')"
indeed does the trick in psyplot.
from psy-maps.
Alright! Thanks for the confirmation :) I'll decide on the next few days how to handle the Datagrid for Curvilinear grids and then close this issue. Any input or suggestions are welcomed!
from psy-maps.
Related Issues (18)
- NEW FEATURE: Implement formatoption widgets
- Problem in displaying dateline crossing for rotated coordinates HOT 2
- Variables without time dimensions greyed out HOT 10
- Projection update does not work with cartopy 0.18
- ICON grid cells at poles are not displayed correctly
- Plotting operational ICON data and benchmarking HOT 6
- Deploy psy-maps docs with CircleCI and GH-Pages
- Add scipy as dependency
- Rotated coordinates are not shown correctly with plot="poly"
- Move psy-maps to psyplot organization
- NEW FEATURE: Visualization of UGRID elements defined on the nodes HOT 9
- display bug with icon-data HOT 2
- Mapplot covers whole figure when using map_extent and saved as .png HOT 1
- mapvector: lonlatbox and density don't work together HOT 5
- Setting a `matplotlib.colors` normalization as `bounds` causes error in `mapcombined`
- ortho projection does not focus on central longitude and latitude
- Strange Figures for rotated coordinates HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psy-maps.