Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python graphics
#1
I just started learning graphing in python and I don't understand what the problem is
import numpy as np
import matplotlib.pyplot as plt

a = np.arange(1, 50, 1)
TTT = 100 + 4*a + 0.25*a*a
FFF = 100 + a*0
VVV = 4*a+0,25*a*a

plt.plot(a, TTT)
plt.plot(a, FFF)
plt.plot(a, VVV)

plt.show()
An error like this is displayed:

Traceback (most recent call last):
  File "C:/Users/Кирилл/Desktop/График.py", line 14, in <module>
    plt.plot(a, VVV)
  File "C:\Users\Кирилл\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\pyplot.py", line 3019, in plot
    return gca().plot(
  File "C:\Users\Кирилл\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes\_axes.py", line 1605, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "C:\Users\Кирилл\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes\_base.py", line 315, in __call__
    yield from self._plot_args(this, kwargs)
  File "C:\Users\Кирилл\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes\_base.py", line 501, in _plot_args
    raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (49,) and (2, 49)
Reply
#2
What are you expecting VVV to be? It is a tuple, containing two arrays. So you are then trying to plot that tuple of 2 arrays against a. I doubt this is what you meant to do.

Change the comma in line 7 to a decimal point. I think that is what you want.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle python graphics Y0sh1 6 3,382 Jun-10-2020, 10:05 AM
Last Post: DPaul
  Python Graphics Help With Entries BadenJaden 1 47,444 Jul-24-2019, 10:36 PM
Last Post: Yoriz
  from graphics import * jmaloney413 2 5,144 Oct-18-2018, 08:22 AM
Last Post: perfringo
  Python catch mouse click in pure text, no graphics samtal 7 7,114 Sep-10-2018, 03:02 PM
Last Post: samtal
  Working with turtle graphics in python and colour slices of a pie graph... netrate 1 4,441 Feb-03-2018, 08:41 PM
Last Post: Larz60+
  Graphics py not found vnc 13 21,182 Apr-05-2017, 05:36 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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