Python Forum
Python graphics - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python graphics (/thread-34832.html)



Python graphics - kaltenherz - Sep-04-2021

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)



RE: Python graphics - jefsummers - Sep-05-2021

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.