Comments (6)
Are you running in a notebook or a script? Please provide a complete example.
from cartopy.
thanks for the reply. I run the code from VScode Jupyter notebook.
Below is the complete code. The plot parameters can be obtained from the attached json file
plot_params.json
The figure I got after running the code is also attached here
import json
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
with open('plot_params.json', 'r') as f:
plot_params = json.load(f)
#
glon_e3d = plot_params['glon_e3d']
gclat_e3d = plot_params['gclat_e3d']
glon_test = plot_params['glon_test']
gclat_test = plot_params['gclat_test']
lon_secs = plot_params['lon_secs']
lat_secs = plot_params['lat_secs']
#
proj = ccrs.LambertAzimuthalEqualArea(central_latitude = clat, central_longitude = clon)
fig,axes = plt.subplots(1,3, figsize=(10,10),subplot_kw={'projection':proj})
axs = axes.ravel()
#
extent = [205, 225, 63, 69]
ax = axs[0]
ax.gridlines()
ax.set_extent(extent, crs=ccrs.PlateCarree())
ax.scatter(glon_e3d, gclat_e3d, transform = ccrs.Geodetic(), c = 'r', marker = '.', label = 'data points', s=10)
#
ax = axs[1]
ax.gridlines()
ax.set_extent(extent, crs=ccrs.PlateCarree())
ax.scatter(glon_test, gclat_test, transform = ccrs.Geodetic(), c = 'r', marker = '.', label = 'data points', s=10)
#
ax = axs[2]
ax.gridlines()
ax.set_extent(extent, crs=ccrs.PlateCarree())
ax.scatter(lon_secs, lat_secs, transform = ccrs.Geodetic(), c = 'r', marker = '.', label = 'data points', s=10)
plt.show()
when the number of axes in the subplots is 1, the figsize parameter affects the actual size of the figure without changing extent of the axis. However, this is not the case when the number of the axes is higher than 1. In addition despite the given width and heights of the fig are equal, the result figure doesn't show that.
from cartopy.
Cartopy's axes all have fixed aspect ratios so will not fill up the figure when arranged like this. The default backend used by Jupyter always resizes the figure to fit around the artists on it. I suspect you will see consistent behaviour if you do a more simple plot without Cartopy:
import matplotlib.pyplot as plt
fig, ax_arr = plt.subplots(1,3, figsize=(10,10))
for ax in ax_arr:
ax.set_aspect('equal')
from cartopy.
thanks for the reply. you are right, I see the same issue with the above code. However, the figure behave as expected when I remove the ax.set_aspect('equal') line. I will leave the issue open in case some one suggests a general solution
from cartopy.
@habtie-phys Right, ax.set_aspect('equal')
is equivalent to what every Cartopy-based plot is doing due to the nature of plotting on geographic projections.
There isn't a general solution to this problem currently given that Matplotlib doesn't have a dynamic layout engine for Axes. Instead Matplotlib provides various APIs for carving out rectangles from a figure, which Axes are then free to adjust within to suit their needs.
Closing since at best anything addressing this would have to happen in Matplotlib itself.
from cartopy.
@dopplershift thank you for the reply. Now I understand that this is not the right place for the issue to remain open.
from cartopy.
Related Issues (20)
- fiona seems to be necessary when plotting coastlines HOT 2
- Feature request: Shading on Orthographic projection HOT 10
- Discontinuous RotatedPole parameters produce inverted coordinate system HOT 3
- The left extent has a boundary when plotting using Cartopy? HOT 2
- Improve documentation of cartopy.feature.NaturalEarthFeature HOT 1
- Deepcopy of CRS Object Fails to Initialize HOT 7
- Services which support only WMS v1.3.0 return error (Only v1.3.0 is allowed)
- 0.23.0 fails to build due to test failures when no network is available HOT 3
- A GEOSException error occurred when calling contourf HOT 3
- Incorrect behavior of GridLiner when setting draw_labels='x'
- Error initializing LambertConformal projection on sphere with 0.23 HOT 2
- Inconsistent plots between uniform grid and non-uniform climate model grid HOT 1
- [TST] Upcoming dependency test failures HOT 2
- [TST] Upcoming dependency test failures
- Issue plotting Any maps.
- `GeoAxes._update_title_position` called before `Gridliner._labels` is populated HOT 7
- Broken WMTS examples in gallery
- Missing y-axis gridline labels when rotated to 90 degrees HOT 2
- Request to add transform_first keyword to barbs HOT 2
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 cartopy.