Python Forum
Error when plotting a graph.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when plotting a graph.
#2
_x is a numpy array. _y is a single number. Do you want to evaluate m_val*x_val+c_val for each value in _x?
import numpy as np
import matplotlib.pyplot as plt

slope = 2
offset = 3
x = np.linspace(-5,5,100)
y = x * slope + offset
plt.plot(x, y)
plt.show()
Another thing. This makes no sense:
x_val = int(Ex.get()) #x_val stands for x value & is used in calculations
x_val is a range, not a single value. You should have the user enter the range for x, not a single value.
Reply


Messages In This Thread
Error when plotting a graph. - by Oshadha - Mar-14-2022, 03:48 PM
RE: Error when plotting a graph. - by deanhystad - Mar-14-2022, 04:06 PM
RE: Error when plotting a graph. - by Oshadha - Mar-14-2022, 04:53 PM
RE: Error when plotting a graph. - by deanhystad - Mar-14-2022, 06:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Plotting by Time, error mansoorahs 1 775 May-16-2023, 09:46 AM
Last Post: Larz60+
  Plotting simple graph (AttributeError) Laplace12 0 1,400 Jul-28-2021, 10:58 AM
Last Post: Laplace12
  Error When Plotting ValueError: x and y must have same first dimension JoeDainton123 1 9,168 Oct-04-2020, 12:58 PM
Last Post: scidam
  Graph not plotting Hass 1 1,993 Sep-14-2019, 09:52 AM
Last Post: luoheng
  Plotting number on graph william888 1 1,746 Sep-02-2019, 02:36 AM
Last Post: scidam
  Graph Plotting Help Talch 1 2,273 Aug-16-2018, 10:29 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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