Python Forum
first time use plot - I get empty graph
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first time use plot - I get empty graph
#1
Hello,
I want to show variable in a graph , I don't have "x" only the value of y
so I thought to create an int for numbers of time I get the speed and increase it every time

I will explain
I'm reading speed senor and I want to create a speed graph
the function read the data from a known file , return and print it - this part works without any problems.
this is what I have

import matplotlib.pyplot as plt

t = 0
def GetDataFunction()
    global t
    Speed = GetData()
    print(f"Speed: {Speed} Km/h ")
    plt.plot(t, float(Speed))
    t += 1

GetDataFunction()

plt.show()
what did I miss?



***
I have try to make it even more simple

import matplotlib.pyplot as plt
 
t = 0
Speed = [0, 1, 3, 50, 60, 22, 30]

def Function():
    global t
    while t < len(Speed):
      print(t, '-', Speed[t])
      plt.plot(t, Speed[t])
      t += 1
    
Function()
but I get the same result - empty graph
I can see the max value is:
Y - 60
X - 6
so something is right :-)

Thanks ,
Reply


Messages In This Thread
first time use plot - I get empty graph - by korenron - Jan-23-2023, 01:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to plot the graph as needed drunkenneo 1 8,316 May-26-2021, 11:04 AM
Last Post: cygnus_X1
  How to plot 3D graph of non numerical value? Gevni 0 2,700 Mar-05-2021, 02:50 PM
Last Post: Gevni
  Python Matplotlib: How do I plot lines with different end point in the same graph? JaneTan 0 2,142 Feb-28-2021, 11:56 AM
Last Post: JaneTan
  Plot Graph quest_ 2 2,937 Jan-18-2021, 07:58 PM
Last Post: quest_
  How to plot intraday data of several days in one plot mistermister 3 3,951 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Bode plot from time series experiment data discus 4 9,894 Jun-20-2020, 07:46 AM
Last Post: discus
  plot multiple employee sales data in a single graph pitanshu 0 2,368 Oct-24-2019, 01:56 PM
Last Post: pitanshu
  Plot multiple csv into one graph problem with visualize linkxxx86 1 6,630 Oct-14-2019, 05:54 PM
Last Post: linkxxx86
  Real time graph of the temperatures and storage linkxxx 3 3,462 Aug-29-2019, 09:44 AM
Last Post: linkxxx
  How to plot vertically stacked plot with same x-axis and SriMekala 0 2,474 Jun-12-2019, 03:31 PM
Last Post: SriMekala

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020