Python Forum
Dynamically plotting graphs with matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamically plotting graphs with matplotlib
#12
It is possible to make a new dataframe that consists of selected columns of another dataframe. If the signal names follow some pattern this can be done using "like".
import pandas as pd
import random


data = {
    "time": range(1000, 1010),
    "sw1": random.choices([0, 1], k=10),
    "sw2": random.choices([0, 1], k=10),
    "tmp1": [random.random() * 5 + 10 for _ in range(10)],
    "sw3": random.choices([0, 1], k=10),
    "tmp2": [random.random() * 5 + 11 for _ in range(10)],
    "tmp3": [random.random() * 5 + 12 for _ in range(10)],
}
df = pd.DataFrame(data)

switches = df.filter(regex=r"(time)|sw.$")
temperatures = df.filter(regex=r"(time)|tmp.$")
Reply


Messages In This Thread
RE: Dynamically plotting graphs with matplotlib - by deanhystad - Apr-17-2024, 04:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to plot 2 graphs in one figure? man0s 1 1,411 Apr-25-2022, 09:18 AM
Last Post: Axel_Erfurt
  Plotting issue Matplotlib garam0 0 1,568 May-23-2020, 12:11 AM
Last Post: garam0
  plotting of graphs mudezda1 2 2,879 Feb-11-2019, 12:44 PM
Last Post: mudezda1
  Tuple Unpacking with graphs in matplotlib smw10c 2 6,056 Mar-23-2017, 05:13 PM
Last Post: smw10c

Forum Jump:

User Panel Messages

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