Проблема с представлением оси X с использованием matplotlib - PullRequest
1 голос
/ 30 октября 2019

Я пытаюсь построить график с блокнотом Jupyter. График отображается в ячейке, но ось X не прикрепляется к графику, а отображается в самом конце ячейки. Когда я добавляю plt.tight_layout, появляется следующее предупреждение Tight layout not applied. The bottom and top margins cannot be made large enough to accommodate all axes decorations.

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,
                               AutoMinorLocator)
from sklearn.linear_model import LinearRegression
from scipy import stats

%matplotlib inline

file = pd.read_excel("T8.xlsx","Phthalansäureanhydrid",usecols=[2,3])
X = file['Zeit(s)']
Y = file['Temperatur(Celcius Grad)']

fig, ax = plt.subplots()
ax.plot(X,Y,'-',color='#10A5F3', label="Phthalansäureanhydrid")
ax.grid(True, which='major', axis='both', color='#F19211', linestyle='-')
#ax.grid(True, which='minor', axis='both', color='#F19211', linestyle='--')
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.legend(loc='upper center', frameon=True)

#major & minor ticks
ax.xaxis.set_major_locator(MultipleLocator(100))
ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.xaxis.set_minor_locator(MultipleLocator(10))

ax.yaxis.set_minor_locator(MultipleLocator(0.1))




plt.xlabel(r'Zeit[s]')
plt.ylabel(r'Temperatur[c]')


plt.tight_layout()
plt.show()

Ссылка на данные: https://docs.google.com/spreadsheets/d/1xznXj-aA-Szq2s4KWb-qPWYxZbQNrA5FgUCQT6i7oVo/edit?usp=sharing

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...