-
Notifications
You must be signed in to change notification settings - Fork 388
Closed
Milestone
Description
Description
In matplotlib it is possible to change the color (face,edge,...) of an object that has already been created. This is not possible with an object created with add_geometries
.
In matplotlib, we can create a plot and change its color with:
import matplolib.pyplot as plt
line, = plt.plot([1,2,3],[4,5,6],'red') #Plot in red
line.set_color('green') #Change the color to green
But in cartopy, the 'geo' object created with the following code will not have any 'color' (or similar) property.:
geo = ax.add_geometries(geometry,facecolor='ghostwhite', edgecolor='black',crs=data_transf)
geo.set_color('green') #Does not exist
This issue is in response to a stackoverflow question.
Code to reproduce
A call to matplotlib.artist.getp
will show that no color
, facecolor
,... exist for a FeatureArtist
from cartopy added with add_geometries
.
For a plot, the call returns:
>>import matplotlib.artist as mart
>>mart.getp(line)
agg_filter = None
alpha = None
animated = False
antialiased = True
children = []
clip_box = TransformedBbox( Bbox(x0=0.0, y0=0.0, x1=1.0, ...
clip_on = True
clip_path = None
color = (1.0, 0.0, 0.0, 1.0)
contains = None
dash_capstyle = butt
dash_joinstyle = round
data = (array([1, 2, 3]), array([4, 5, 6]))
drawstyle = default
figure = Figure(640x476)
fillstyle = full
gid = None
in_layout = True
label = _line0
linestyle = -
linewidth = 1.5
marker = None
markeredgecolor = (1.0, 0.0, 0.0, 1.0)
markeredgewidth = 1.0
markerfacecolor = (1.0, 0.0, 0.0, 1.0)
markerfacecoloralt = none
markersize = 6.0
markevery = None
path = Path(array([[ 1., 4.], [ 2., 5.], ...
path_effects = []
picker = None
pickradius = 5
rasterized = None
And for a geometry, it returns:
>>mart.getp(geo)
agg_filter = None
alpha = None
animated = False
children = []
clip_box = TransformedBbox( Bbox(x0=0.0, y0=0.0, x1=1.0, ...
clip_on = True
clip_path = None
contains = None
figure = Figure(1200x990)
gid = None
in_layout = True
label =
path_effects = []
picker = None
rasterized = None
sketch_params = None
snap = None
transform = CompositeGenericTransform( TransformWrapper( ...
transformed_clip_path_and_affine = (None, None)
url = None
visible = True
zorder = 1
We can see that the properties related to colors are missing.
Metadata
Metadata
Assignees
Labels
No labels