So entfernen Sie den Symbolteil vor Text in der Legende in MatplotlibPython

Python-Programme
Guest
 So entfernen Sie den Symbolteil vor Text in der Legende in Matplotlib

Post by Guest »

Ich habe diese benutzerdefinierten Legenden in den hinzugefügt Angehängte Handlung, aber es hat einen seltsamen Raum vor dem Text. Gibt es eine Möglichkeit, den leeren Speicherplatz zu entfernen? < /P>
Code: < /p>

Code: Select all

# Plotting
plt.figure(figsize=(7, 5))  # Set figure size
plt.plot(time_vector[:len(volumes)], np.array(volumes)*1e3)

# Add labels with fontsize 15
plt.xlabel("Time (h)", fontsize=25)
plt.ylabel("Flow Volume (mL)", fontsize=25)

# Define custom legend
custom_lines = [
Line2D([0], [0], color='none', marker=None, linestyle='None', label=f'Initial Flow Volume : 0.78 (mL)'),
Line2D([0], [0], color='none', marker=None, linestyle='None', label=fr'Flow Ramp Factor : 0.170 (h$^{{-1}}$)'),
Line2D([0], [0], color='none', marker=None, linestyle='None', label=f'Feeding Interval : 4.434 (min)'),
]

# Add the custom legend
plt.xticks(fontsize=25)  # Set x-tick font size
plt.yticks(fontsize=25)  # Set y-tick font size
plt.legend(handles=custom_lines, fontsize=20)  # Set legend font size
figure_path = os.path.join('figures','figure6','figure6a.svg')
plt.savefig(figure_path, format="svg", bbox_inches="tight", dpi=300)
plt.show()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post