Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
How can write a program to graph two different data (x=data1 & y=data2 )?
+1
vote
asked
Dec 5, 2019
by
Angel
Hello
I'm making a tool that measure several sensors non stop. I would like to make a graph in real time while the sensors are still measuring, but with recalculated data. The two variables I want to plot in a graph are x=speed and y=force.
Could anyone help me with the code please?
Should I first log some data in a csv file?
How can I make the graph?
python-3
python
3
8
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
1 Answer
+2
votes
answered
Dec 11, 2020
by
Tushar Khanna
(
190
points)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
speed=np.array([1,2,3,4,5])
force=np.array([6,7,8,9,10])
plt.plot(speed,force)
plt.show()
commented
Jan 23, 2021
by
Ubirajara Costa
(
100
points)
It doesn't work in this environment.
When I try the provided code I keep getting the following:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import pandas as pd
File "/usr/lib/python3/dist-packages/pandas/__init__.py", line 40, in <module>
from pandas.core.api import *
File "/usr/lib/python3/dist-packages/pandas/core/api.py", line 12, in <module>
from pandas.core.series import Series, TimeSeries
File "/usr/lib/python3/dist-packages/pandas/core/series.py", line 2617, in <module>
import pandas.tools.plotting as _gfx
File "/usr/lib/python3/dist-packages/pandas/tools/plotting.py", line 23, in <module>
import pandas.tseries.converter as conv
File "/usr/lib/python3/dist-packages/pandas/tseries/converter.py", line 7, in <module>
import matplotlib.units as units
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 967, in <module>
rcParams = rc_params()
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 876, in rc_params
fname = matplotlib_fname()
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 744, in matplotlib_fname
configdir = _get_configdir()
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 613, in _get_configdir
return _get_config_or_cache_dir(_get_xdg_config_dir())
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 590, in _get_config_or_cache_dir
return _create_tmp_config_dir()
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 522, in _create_tmp_config_dir
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
File "/usr/lib/python3.4/getpass.py", line 170, in getuser
return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 14072'
...Program finished with exit code 1
Press ENTER to exit console.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...