def create_plot(json_data, output):
all_data = pd.DataFrame(json_data)
df = all_data[all_data['ProductDescription'] == 'Linux/UNIX']
df = df.drop_duplicates(subset=['DateTime', 'AvailabilityZone', 'InstanceType'])
x_min = df['DateTime'].min()
x_max = df['DateTime'].max()
border_pad = (x_max - x_min) * 5 / 100
g = sns.FacetGrid(
df,
col='InstanceType',
hue='AvailabilityZone',
xlim=(x_min - border_pad, x_max + border_pad),
legend_out=True,
size=10,
palette="Set1"
)
g.map(plt.scatter, 'DateTime', 'SpotPrice', s=4).add_legend()
plt.subplots_adjust(top=.9)
g.fig.suptitle('AWS Spot Prices between {start} and {end}'.format(start=x_min, end=x_max))
g.savefig(output, format='png')
评论列表
文章目录