Я строю некоторые данные, импортированные из файла CSV ; простой линейный график работает хорошо, за исключением того, что есть точки, выглядящие грязно, где точки данных соединяются (они странно расположены под углом и дают графику общий загроможденный вид) .
Я хочу перейти к точечной диаграмме с линиями между точками, надеясь, что это устранит проблему. Однако, когда я строю точечную диаграмму, дата и время из моего csv отклоняются, и отображается следующее сообщение об ошибке .
У кого-нибудь есть идеи, как я могу использовать csv datetime с точечной диаграммой. Или, еще лучше, как я могу остановить эти раздражающие грязные линии в линейном графике? Этот последний будет идеальным вариантом.
Сообщение об ошибке для решения .values ...
Мой код указан ниже:
import matplotlib.pyplot as plt
import pandas as pd
import os
import matplotlib.dates as mdates
# Read the file in csv
File = pd.read_csv("Timeline.csv")
# Where to save the output
outputDirectory = 'Z:\\15_Hawaii\\Plotting\\'
if not os.path.exists(outputDirectory):
os.makedirs(outputDirectory)
# Datetime selection
time = File.iloc[:,0]
time_time = pd.to_datetime(time, format = '%m/%d/%Y')
time_time = pd.to_datetime(time_time, format = '%m/%d/%Y')
time_day = mdates.DayLocator()
# Kona data selection
Kona = File.iloc[:,2]
# defining the names which will be called
fig, host = plt.subplots()
ax = plt.gca()
# simple plot of the data
K_plot, = host.plot(time_time, Kona, color=[0,0.690196078,0.941176471], linewidth=1, label="Kona")
# attempt to scatter plot the data
K_plot, = plt.scatter(time_time, Kona, color=[0,0.690196078,0.941176471], linewidth=1, label="Kona")
# other plotting parameters
ax.xaxis.grid(linestyle='dotted')
plt.setp(ax.xaxis.get_majorticklabels(), rotation=80 )
fig.set_size_inches(12, 5)
plt.savefig(outputDirectory + 'SO2_PLOT_1' + '.png', bbox_inches='tight', dpi=300, pad_inches=0.0)