Python Forum

Full Version: Python graphics
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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.