[英]Is there a way to create a bar graph visualization with plotly or python where the y-axis is 24hour range and x-axis is all the weekdays?
[英]Is there a way to create a graph that has iterated pairs of consecutive items in its own x-axis and values of the pairs in its own y-axis?
我想遍歷列表中稱為 ObjectID 的所有成對連續項目,然后我想要 plot 並演示一個 2D 圖,該圖顯示名為 Slops 的列表中兩個特定節點/點之間的每個斜率值。
meterBetweenTwoPoints = 5
currentPointDateTimes = []
objectHeights = []
objectIDs = []
objectsIDsForGraphNodes = []
slopeValues = []
..
for x in range(0, len(objectHeights)):
objectsIDsForGraphNodes.append(objectIDs[sortedIndexLibrarycurrentPointDateTimes[x]])
print(objectsIDsForGraphNodes)
>> [1480642, 1504454, 1504455, 1504456, 1504457, 1504458]
for x in range(0, len(objectHeights)-1):
pointXHeight = objectHeights[sortedIndexLibrarycurrentPointDateTimes[x]]
pointYHeight = objectHeights[sortedIndexLibrarycurrentPointDateTimes[x+1]]
currentSlopeValue = ((pointYHeight - pointXHeight) / meterBetweenTwoPoints) * 100
slopeValues.append(currentSlopeValue)
print(slopeValues)
>> [-14.6541400000001, -4.927820000000054, -2.8426600000000235, -2.2563800000000356, -1.0200999999997862]
因此,這意味着我有 6 個不同的節點和 5 個不同的斜率值。
如您所見,列表的大小不相等,但我可以為名為 slopeValues 的列表分配一個額外的“零”。 我可以將列表轉換為數據框,但仍然無法做到。
我的環境不支持像“plotly”這樣的庫。
我准備了一個可視化來明確我的請求/需求:
此圖表示所需的 output。我使用 matplotlib、seaborn 和 pandas 嘗試了多種解決方案,但無法執行 output。
除此之外,是否有更好的可視化來顯示特定點(道路)之間的傾斜度/坡度值?
在此先感謝,我很感激。
import matplotlib.pyplot as plt
X = [1480642, 1504454, 1504455, 1504456, 1504457, 1504458]
Y = [-14.6541400000001, -4.927820000000054, -2.8426600000000235, -2.2563800000000356, -1.0200999999997862]
#Custom X tick text
X_ticks = ['['+ str(X[i]) + '-' + str(X[i+1]) +']' for i in range(0,len(X)-1)]
# add 0 to make list size equal
X_ticks.insert(0, 0)
Y.insert(0,0)
#Draw Plot
plt.figure(1, figsize = (12,6))
plt.suptitle('Slope Plot')
ax = plt.gca()
x_axis = range(0,len(X_ticks))
ax.set_xlim([0, len(X_ticks)])
ax.set_ylim([0, min(Y) - 2 ])
# Draw horizontal lines
for v in Y:
plt.axhline(y=v, color='g', linestyle='--')
plt.xticks(x_axis, X_ticks)
plt.yticks(Y)
plt.plot(x_axis, Y, 'ro--')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.