Ich versuche, den folgenden Pandas Datenrahmen zu plotten (Erste Spalte ist der Index):Plotten Fehler mit matplotlib (kein x-Tick-Label)
pressure mean pressure std Time
Time
00:00:00 618.663133 0.108484 00:00:00
01:00:00 618.281129 0.111788 01:00:00
02:00:00 617.975430 0.101657 02:00:00
03:00:00 617.766129 0.062712 03:00:00
04:00:00 617.807043 0.066030 04:00:00
05:00:00 617.976479 0.079755 05:00:00
06:00:00 618.276720 0.118224 06:00:00
.........
Mein Ziel ist es Zeit zu plotten (x-Achse) vs Druckmittelwert (y-Achse). Ich möchte die X-Achse mit 2-Stunden-Ticks und H: M-Format sein. Ich bin mit dem folgenden Code:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
fig = plt.figure(figsize=(15,7))
ax = fig.add_subplot(1,1,1) # row-col-num
# --- line plot data on the Axes
ax.plot(df6['Time'], df6['pressure mean'], 'b-', linewidth=2,
label=r'Hawaii Pressure')
# -- Tick Label Size --
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['ytick.labelsize'] = 16
# -- Tick Labels Format --
DaysFmt = mdates.DateFormatter('%H:%M')
minorLocator = MultipleLocator(5)
ax.xaxis.set_minor_locator(minorLocator)
ax.xaxis.set_major_formatter(DaysFmt)
# -- Axis Labels --
ax.set_ylabel(r'Pressure $[mb]$', fontsize=22)
ax.set_xlabel(r'Hour', fontsize=22)
# -- Tick Limits and Labels --
ax.xaxis.set_major_locator(mdates.HourLocator(interval=2))
# -- Legend and Grid --
ax.legend(loc='best')
ax.grid(True)
# -- Title --
fig.suptitle('Stacked Hourly Pressure Averages (1 month)',fontsize=27)
fig.tight_layout(pad=5)
# -- Intervals --
fig.savefig('Hawaii Stacked Pressure October 2016.png', dpi=300)
aber ich bin ein Speicherfehler bekommen, ich weiß es, weil der folgenden Zeile ist:
ax.xaxis.set_minor_locator(minorLocator)
Wenn ich die Zeile löschen - ich bin ein Diagramm ohne X-Achsen-Tick-Label bekommen!
Irgendwelche Vorschläge? Danke !!
Siehe http://stackoverflow.com/help/mcve – user2699