matplotlib

How to add a live (updating) graph to my PyQt5 Window using Serial?

我们两清 提交于 2021-02-11 12:34:52
问题 I am writting a program that's supposed to receive 4 random values from my Arduino every second and create an updating bar chart with them. I then want to create a PyQt5 Window to show that bar chart. I was sucessful at reading the values coming from my Arduino and using them to create the bar chart. However, since I'm a beginner when it comes to GUI/Arduino, I have no clue how to add that bar chart to my PyQt Window. I'd appreciate if you could help me with that. Here's my Arduino code: void

plot doesn't update on button click but does when window resized

纵饮孤独 提交于 2021-02-11 12:34:09
问题 What's going on: Program in python3/qt5/matplotlib. I am plotting three subplots and few plots in each. I wanted to update plots if user changes any data. That proved rather complicated hence the button 'Replot'. It calls a function that clears canvas and ... reloads the entire widget. It doesn't work as expected: when I press the button nothing happens, but when window gets resized after button clicked it does update the plot. What would be a correct way to do it without having to put all

How to add a live (updating) graph to my PyQt5 Window using Serial?

ぃ、小莉子 提交于 2021-02-11 12:34:07
问题 I am writting a program that's supposed to receive 4 random values from my Arduino every second and create an updating bar chart with them. I then want to create a PyQt5 Window to show that bar chart. I was sucessful at reading the values coming from my Arduino and using them to create the bar chart. However, since I'm a beginner when it comes to GUI/Arduino, I have no clue how to add that bar chart to my PyQt Window. I'd appreciate if you could help me with that. Here's my Arduino code: void

Matplotlib Line vs. Bar plot DateTime axis formatting

ⅰ亾dé卋堺 提交于 2021-02-11 12:29:30
问题 I have a DataFrame with a DateTime index: import pandas as pd from random import randrange dates = pd.date_range(start="2020-02-01",end='2020-04-18',freq='1d') df = pd.DataFrame(index=dates,data=[randrange(10000) for i in range(78)] Now when I plot the data as a line plot, matplotlib produces a nicely formatted x axis: df.plot(figsize=(12,4)) However, if instead I do a bar plot, I now get something quite horrible: df.plot(kind='bar',figsize=(12,4)), This is quite disconcerting, as it is the

Plotting 3D brain image Python

自古美人都是妖i 提交于 2021-02-11 12:28:43
问题 I have a data set of brain which is in .nii.gz format to work on neural network I used nilearn package to read the file and get the image data. The shape of the image is (256, 256, 150) I can plot the 2D image from slicing the image using Matplotlib but, How can I plot the image in 3D using Python Thanks 来源: https://stackoverflow.com/questions/62256355/plotting-3d-brain-image-python

Set precision on custom ticks with scientific style

与世无争的帅哥 提交于 2021-02-11 12:20:34
问题 I have produced this code to generate the following graph: import matplotlib.pyplot as plt import numpy as np x = np.linspace(1/10000, 1/2000, 13) y = x**2 plt.plot(x, y, 'ro') plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0), useMathText=True) I would like to set the xticks at the position of the data. If I then do plt.xticks(x, rotation=45) I get the ticks at the desired locations but with too many decimal places (see next picture). How do I get the ticks at the specified

Creating a grouped sorted bar plot using pandas

戏子无情 提交于 2021-02-11 09:41:23
问题 I have been trying to create a grouped sorted bar plot such as this one http://chrisalbon.com/python/matplotlib_grouped_bar_plot.html from a DataFrame created from dict by doing: food = {'Apples as fruit': 4.68, 'Berries': 7.71, 'Butter': 12.73, 'Cheese': 4.11, 'Dairy, Other': 4.97} dframe = pd.DataFrame([food]) dframe.plot(kind='bar') Apples as fruit Berries Butter Cheese Dairy, Other 0 4.68 7.71 12.73 4.11 4.97 The first group should have Apples and Berries and the second should have Butter

Why is the first of the month automatically plotted as tick in matplotlib.plot_date?

萝らか妹 提交于 2021-02-11 09:40:49
问题 I have a geodataframe with date as string and Date as a datetime64[ns]. I am using matplotlib 3.0.2. I've tried clearing the data using plt.cla() , plt.clear() and plt.clf( ) as mentioned in other posts and questions but no matter what, the data plots what seems to be a major and minor axis formatting without any prompting - assuming that in plot_date the first of the month is the "major" axis. This is my graph (edited for clarity). It seems caused by new updates in 3.0.2 (from 2.1.0) it's

Why is the first of the month automatically plotted as tick in matplotlib.plot_date?

柔情痞子 提交于 2021-02-11 09:40:33
问题 I have a geodataframe with date as string and Date as a datetime64[ns]. I am using matplotlib 3.0.2. I've tried clearing the data using plt.cla() , plt.clear() and plt.clf( ) as mentioned in other posts and questions but no matter what, the data plots what seems to be a major and minor axis formatting without any prompting - assuming that in plot_date the first of the month is the "major" axis. This is my graph (edited for clarity). It seems caused by new updates in 3.0.2 (from 2.1.0) it's

Why is the first of the month automatically plotted as tick in matplotlib.plot_date?

亡梦爱人 提交于 2021-02-11 09:40:05
问题 I have a geodataframe with date as string and Date as a datetime64[ns]. I am using matplotlib 3.0.2. I've tried clearing the data using plt.cla() , plt.clear() and plt.clf( ) as mentioned in other posts and questions but no matter what, the data plots what seems to be a major and minor axis formatting without any prompting - assuming that in plot_date the first of the month is the "major" axis. This is my graph (edited for clarity). It seems caused by new updates in 3.0.2 (from 2.1.0) it's