Reputation: 706
I've encountered a strange issue when using matplotlibs fill_between with data that has a tight gap. For example, when I simply want to plot the following data and save it as SVG, it works:
import matplotlib.pyplot as plt
plt.fill_between([0,1e4-1000,1e4,1e4+1000,1e6], [1000,1000,1,1000,1000])
plt.savefig("test.svg")
But when I set the color to any value, the gap disappears:
import matplotlib.pyplot as plt
plt.fill_between([0,1e4-1000,1e4,1e4+1000,1e6], [1000,1000,1,1000,1000], color='tab:red')
plt.savefig("test_colored.svg")
After zooming in I noticed the edge line is drawn with rounded borders:
How can I change the plot color without this gap disappearing?
I've tried to set different kwargs like capstyle
, joinstyle
, antialiased
, rasterized
,... to all possible values without success.
Upvotes: 0
Views: 348
Reputation: 339220
You are setting the color
of the patch. This would include the edgecolor and the facecolor. However, it seems you only want to have the face colored. Hence use facecolor='tab:red'
import matplotlib.pyplot as plt
plt.fill_between([0,1e4-1000,1e4,1e4+1000,1e6], [1000,1000,1,1000,1000], facecolor='tab:red')
plt.savefig("test_colored.svg")
plt.show()
Upvotes: 1