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

Arcs and Ellipses look like polylines #825

Open
ghost opened this issue Dec 9, 2016 · 6 comments
Open

Arcs and Ellipses look like polylines #825

ghost opened this issue Dec 9, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented Dec 9, 2016

Hi,
In Matplotlib, Ellipses (and Ellipses Arcs) are drawn using Bezier splines, as explained here.
When using Cartopy, it looks to me like the projection of these splines is not so nice as with vanilla Matplotlib.
The last test below gives this image:
figure_ellipse

Thanks!

import math

from matplotlib import patches
import matplotlib.pyplot as plt

import cartopy.crs as ccrs
from cartopy.io.img_tiles import OSM

def setup_osm():
  osm = OSM()
  proj = osm.crs  
  ax = plt.axes(projection=proj)
  ax.add_image(osm, 5)
  return ax
  
def setup_stock_img():
  ax = plt.axes(projection=ccrs.PlateCarree())
  ax.stock_img()
  return ax

def plot_arc(ax):
  ax.add_patch(patches.Arc(
      (2.0, 44.0), 
      width = 2.0 / math.cos(math.radians(44.0)),
      height = 2.0,
      angle = 0.0,
      theta1= 90.0,
      theta2= 180.0,
      fill=False,
      linewidth=2,
      transform=ccrs.Geodetic()))
  ax.set_extent((-2.0, 4.0, 41.0, 47.0))
  plt.show()
  
def plot_ellipse(ax):
  ax.add_patch(patches.Ellipse(
      (2.0, 44.0), 
      width = 2.0 / math.cos(math.radians(44.0)),
      height = 2.0,
      angle = 0.0,
      fill=False,
      linewidth=2,
      transform=ccrs.Geodetic()))
  ax.set_extent((0.0, 4.0, 42.0, 46.0))
  plt.show()  

plot_arc(setup_stock_img())
plot_arc(setup_osm())
plot_ellipse(setup_osm())
@ResidentMario
Copy link

+1 to this. This effect is obvious and rather undesirable here also, in the cartopy example gallery.

@kaspervanwijk
Copy link

I had noticed the behaviour as well, and resorted to using tissot, instead, for smooth circles on maps. This does not help if you need ellipses, though.

@ajdawson
Copy link
Member

This seems to be a problem with how the arcs/ellipses are represented and drawn after a projection. If there is no projection transform the objects appear as expected. This is not simply due to a poor choice of projection threshold.

@ResidentMario - The example gallery problem is actually slightly different to the problem here, although it looks the same, it is to do with the projection threshold being too large.

@pelson
Copy link
Member

pelson commented Jan 15, 2019

Came up in https://stackoverflow.com/questions/54192575/matplotlib-circle-patch-does-not-have-smooth-edges.
I've been working on a Path interpolator that would allow us to fine-tune the path as we zoom in (in matplotlib). Might prove to be a really workable solution for this problem.

@kaspervanwijk
Copy link

kaspervanwijk commented Jan 19, 2019 via email

@sergio-dr
Copy link

sergio-dr commented Dec 28, 2022

Is there any workaround for ellipses? (I'm using PlateCarree). Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants