我有一个简单的python脚本,用于使用seaborn读取CSV文件和绘制图形,并且效果很好!
首先:这是我的CSV文件的屏幕截图,显示了站点的帧和统计信息:
这是我的简单代码:
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns
read_CSV_stats_per_day_for_KS = pd.read_csv('results_per_day/ALL_stations_together.csv', sep=";", encoding ="ISO-8859-1")
read_day_column = read_CSV_stats_per_day_for_KS[read_CSV_stats_per_day_for_KS['day'] == 0]
def plot_results_about_south_east_stations():
south_east = read_day_column[read_day_column['Region'] == 'south_east']
top4_visited_stations = south_east.nlargest(4, 'total_visited_cars')
dataframes_for_south_east_stations = read_CSV_stats_per_day_for_KS[read_CSV_stats_per_day_for_KS['name'].isin(top4_visited_stations['name'])]
sns.relplot(x='day', y='avg_queue_length', data=dataframes_for_south_east_stations, hue='name', kind='line')
plt.suptitle("South-east Oslo")
sns.relplot(x='day', y='avg_total_EV_in_station', data=dataframes_for_south_east_stations, hue='name', kind='line')
plt.suptitle("South-east Oslo")
sns.relplot(x='day', y='total_rejected_cars', data=dataframes_for_south_east_stations, hue='name', kind='line')
plt.suptitle("South-east Oslo")
sns.relplot(x='day', y='total_exhausted_cars', data=dataframes_for_south_east_stations, hue='name', kind='line')
plt.suptitle("South-east Oslo")
plt.show()
当我绘图时,会得到那些漂亮的图形:
如果您在下面的图表上查找(完全相同),我正尝试用特定站点具有的total_amount_of_chargers替换站点名称
问题1:首先,数字有误,我想显示的是充电器的实际数量,而不是20、40、60、80。我该怎么办?问题2:我仍然希望电台名称保留在Y标签上而不是数字上,我该怎么做?
问题3:最后一个问题,是否可以将车站名称和充电器总数结合起来显示在右边?像这样:
这是可能的,那太棒了,我将不胜感激!
谢谢。