Reputation: 2993
Some time ago I asked how to set line style through a function taking the plot axes instance as parameter (matplotlib set all plots linewidth in a figure at once).
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(10))
ax.plot(2 * range(10))
solution suggested:
def bulk_lw_edjuster(ax, lw = 5)
for ln in ax.lines:
ln.set_linewidth(lw)
As shown above one suggested to use ax.lines in the function, but now I would like to know how to set other properties such as marker properties, colors ...
Upvotes: 0
Views: 480
Reputation: 13610
You can find information about the setting the properties of Lines2D here. Marker size and marker color can be set similarly to the line width:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(10))
ax.plot(2 * range(10))
#solution suggested:
def bulk_lw_edjuster(ax, lw = 5, markersize = 5, markerfacecolor = 'r'):
for ln in ax.lines:
ln.set_linewidth(lw)
ln.set_markersize(markersize) # set marker size
ln.set_markerfacecolor(markerfacecolor) # set marker color
# Change the plot properties.
bulk_lw_edjuster(ax, lw =10, markersize = 10, markerfacecolor = 'm')
plt.show()
Upvotes: 2