opendrift
opendrift copied to clipboard
Trying to plot stranded plastics with a different color
trafficstars
Using example_plast as a starting point, I'm trying to get o.plot() to show stranded plastics in a different color. I had a look in the code, and it seems colors are decided by the dictionary status_colors. I tried passing this as an argument to the drifter class:
o2 = PlastDrift(loglevel=20)
o2.add_reader([reader_norkyst])
o2.seed_elements(lon, lat, radius=50, number=3000, time=time, wind_drift_factor=0.1, terminal_velocity=0.02, status_colors={'initial': 'green', 'active': 'blue', 'stranded':'red'})
But this gives me an error message:
TypeError: Redundant arguments: ['status_colors']
Is there another way to achieve the different colors?
Yes, status_colors is not an input parameter to the plot methods (it could have been), but instead a property of the class, and can thus have different default values for different classes.
So you can set it before your plotting:
o2.status_colors={'initial': 'green', 'active': 'blue', 'stranded':'red'}