简体   繁体   English

Python:如何在python中为一个x值绘制y值数组

[英]Python: How to plot an array of y values for one x value in python

I am trying to plot an array of temperatures for different location during one day in python and want it to be graphed in the format (time, temperature_array). 我试图在一天中用python在不同位置绘制温度数组,并希望将其以格式(时间,温度数组)绘制。 I am using matplotlib and currently only know how to graph 1 y value for an x value. 我正在使用matplotlib,目前仅知道如何将1 y值绘制为x值。

The temperature code looks like this: Temperatures = [[Temp_array0] [Temp_array1] [Temp_array2]...] , where each numbered array corresponds to that time and the temperature values in the array are at different latitudes and longitudes. 温度代码如下所示: Temperatures = [[Temp_array0] [Temp_array1] [Temp_array2]...] ,其中每个编号的数组都对应于该时间,并且数组中的温度值在不同的纬度和经度上。

Try this code: 试试这个代码:

import matplotlib.pyplot as plt
plt.plot(times, temperatures, 'ro')
plt.axis([min(times)-1, max(times)+1,
          min(temperatures)-1, max(temperatures)+1])
plt.show()

It should make a dot plot of temperatures over times. 它应该绘制温度随时间变化的点图。

You can simply repeat the X values which are common for y values 您可以简单地重复y值通用的X值

Suppose [x,x,x,x],[y1,y2,y3,y4] 假设[x,x,x,x],[y1,y2,y3,y4]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM