Как удалить часть символа перед текстом в легенде в matplotlib ⇐ Python
Как удалить часть символа перед текстом в легенде в matplotlib
Я добавил эти пользовательские легенды в Прикрепленный сюжет, но у него есть странное пространство перед текстом. Есть ли способ удалить пустое пространство? < /P>
код: < /p>
# 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()
Подробнее здесь: https://stackoverflow.com/questions/794 ... matplotlib
Я добавил эти пользовательские легенды в Прикрепленный сюжет, но у него есть странное пространство перед текстом. Есть ли способ удалить пустое пространство? < /P>
код: < /p>
# 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()
Подробнее здесь: https://stackoverflow.com/questions/794 ... matplotlib
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение