skip to Main Content

I am attempting to save a plot in “layers”. First I want to save just the grid. Then I want to save just my scatter points. And finally I want to save just my trend line, but I can’t figure out how to “turn off” my scatter points to do this. My reasoning for doing this is so that I can import each component of the graph as a layer in photoshop.
Here’s my code:

FIRST PLOT GRID ONLY

fig=plt.figure()
ax1=fig.add_subplot(111)
#ax1.plot(x,p(x), linewidth=3.0, color="#daa004")
plt.ylim(top=72)
plt.ylim(bottom=60)
plt.xlim(right=2025)
plt.xlim(left=1895)
plt.grid(axis='x', alpha=0.4)
plt.grid(axis='y', alpha=0.4)
plt.savefig('MeanAnnualFallTMAX_Grid.png', transparent=True)

PLOT SCATTER ONLY

ax1.plot(x,y,'o',markersize=3,color="#daa004",label="Annual Mean Fall Maximum Temperature")
plt.axis('off')
plt.savefig('MeanAnnualFallTMAX_Scatter.png', transparent=True)

PLOT TREND ONLY (The problem)

ax1.plot(x,p(x), linewidth=3.0, color="#daa004")
plt.axis('off')
plt.savefig('MeanAnnualFallTMAX_Trend.png', transparent=True)

But this prints the scatter and the trend. Is there a way to “clear” or “turn-off” the scatter points I previously plotted?

2

Answers


  1. if you save a reference to your line you may either

    • Turn the points invisible

      line, = ax1.plot(x,y,'o')
      # ...
      line.set_visible(False)
      
    • Remove the points from the axes

      line, = ax1.plot(x,y,'o')
      # ...
      line.remove()
      
    Login or Signup to reply.
  2. I think for this workflow I’d at least try to save the figure as svg and open this in Inkscape. Ungrouping the results there gives access to every partof the figure.
    However, it’ll soon be divided into too small pieces like points or lines, but have a look – perhaps it helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search