Questions tagged [matplotlib]

17982 questions
1

votes
1

answer
50

Views

how to convert pandas time data into the format that can be processed by matplotlib

in the 3 section of lecture, i encounrtered a problem that I could not upload any finance data from yahoo, so I use pandas datareader to uploaded a stock info for microsoft here is that code: MS= data.DataReader(name = 'MSFT', data_source = 'yahoo', start = '2007-07- 10', end = '2008-12-10') MS.head...
Xiaoyang Wu
1

votes
1

answer
794

Views

Python > Matplotlib > Animated live plot > framerate

this is my first question post. Im seeing a refresh rate of about 1 frame every 5 seconds in my live plot using the below code. I want to see something close to real-time updates. The serial rate of the data being plotted is sufficient to support at least 2 frames per second. I've built this sim...
Matt Bauer
1

votes
0

answer
75

Views

PyQt4 not found, despite file existing on the backend folder.

I am trying to run a code to get an interactive GUI. However, I get the following error while trying to use %matplotlib qt: So, I tried using %matplotlib qt5 and the problem still persists. I've checked the backends folder. I seem to have both backend_qt4agg and backend_qt5agg. I am using Conda 4....
hegdep
1

votes
1

answer
64

Views

Currently Animating Scatter Plot With Static Frames. Is there a way to animate over a moving window instead?

I have an array of arrays with format [2000][200,3] that I am creating an animated scatter plot of. 2000 is the number of frames and the interior arrays have format [length, [x,y,inten]] which are the points to scatter. So for an example a single frame will look like: Array[0]=np.array([x_1,y_1,I_1...
Ian Campbell Moore
1

votes
0

answer
83

Views

Draw plot on a supercomputer using ipython

I want to plot a figure using python on a supercomputer. For example, I wrote a script plot.py: import numpy as np import matplotlib.pyplot as plt .... .... plt.plot(m) # m is a matrix with size (1000,36) plt.show() If I do: python3 plot.py there is no picture. But I can get all other numerical...
Shuaishuai Yuan
1

votes
0

answer
2.8k

Views

Python ImportError "cannot import name 'multiarray'

I'm trying to simply import numpy into a python script (called 'MatPlotLib.py using PyCharm) and I'm receiving this odd error. It worked fine, but then I started messing around with Jupyter. I tried uninstalling and reinstalling Python, then a system restore, but nothing seems to be working. I th...
Alex Borg
0

votes
2

answer
24

Views

How to read in user input on a webpage in Flask

I'm trying to create a basic web app that has an HTML form on the root landing page, and then after submission, run a postgresql query with the desired input and redirect the user to a page with a generated matplotlib chart of their input. In my main function, I have the following: @app.route('/', m...
danielschnoll
0

votes
0

answer
3

Views

Analysing the residual normal probability plot

It's very basic question. I want to analyze the standardized residuals of the Linear Regression model. So I did the residual normal probability plot as following: model = LinearRegression(fit_intercept=True) x = df.temp x = np.asarray(x).reshape(-1, 1) model.fit(x, df.RH) y_predicted = model.predict...
demo
1

votes
2

answer
545

Views

Make seaborn swarmplot width the same as the violin

I am trying to plot a swarplot on top of a violin plot. Is there any way to make the swarm width to be shortened just like the width option from violin plot? Would it be easier to use a matplotlib.scatter to do it instead of seaborn.swarmplot? import seaborn as sns data = pd.read_csv('allparticles....
João Mamede
1

votes
1

answer
291

Views

3d plot of list of (hist, bin_edges) where histogram bar chart or lines are in the z-y plane

EDIT - reworked question I need to print a 3D histogram of fitness data for 50 generations of computer programmes. This data is in calculated and stored in a logbook using the DEAP framework. The form of the plot needs to be with the fitness frequency on the z axis, generation on the x axis and bi...
Blue Shrapnel
1

votes
1

answer
529

Views

Python - 2/3D scatter plot with surface plot from that data

Using: [python] [numpy] [matplotlib] So I have a 3D array to create a scatter plot making a n * n * n cube. Those points have different values of potential represented by colors. size = 11 z = y = x = size potential = np.zeros((z, y, x)) Positive = 1...
Vasco Caniça
1

votes
1

answer
656

Views

Legend based on edge color in networkx

Is there a way to create a legend in networkx based on edge color (as opposed to by node color)? This is my graph: plt.figure(figsize = (15, 10)) G = nx.from_pandas_dataframe(df, 'From', 'To', ['Order', 'Colors']) edge_labels = nx.get_edge_attributes(G, 'Order') nx.draw_networkx(G, with_labels = Fal...
jbachlombardo
1

votes
0

answer
168

Views

Pandas plot table is not plotting all the columns

I am trying to plot the dataframe which is represented in an image. def count_of_each_categories(self,y_train=None,y_test=None,technology_segment=None): ''' :param y_train: :param y_test: :return: ''' df_train = pd.DataFrame() df_train[technology_segment] = y_train df_test = pd.DataFrame() df_train...
Nitesh kumar
1

votes
1

answer
155

Views

import cv2 terminal error - python

I'm trying to simply install and use cv2, numpy and matplotlib. All installed successfully but when I type into the terminal 'import ...' it gives me the following error? I'm confused because what the terminal is suggesting, I've already installed it that way? I'm not sure about why it's pointin...
BBKING
1

votes
1

answer
418

Views

Plotting quadrants with axvspan

I am trying to plot four colored quadrants on a plot with a range of [-0.2,1.4] and [-0.2,1.4]. The issue is I'm having trouble trying to line up the y axis coordinates of the quadrants using plt.axvspan: roc_t = 0.43652219 roc_v = 0.82251961 plt.figure() plt.figure(figsize=(15,12)) plt.xlim(-0.2,1....
AToe
1

votes
0

answer
112

Views

Matplotlib.animation performance with Axes3D

I have played with creating HTML5 videos from matplotlib.animation.Artistanimation, it works well for both 2D and 3D images, but for the 3D version, the conversion to html5 video is very slow, like 200s for 35 frames. Given that it takes roughly 3 times longer to draw a 3D figure than a 2D figure,...
kakk11
1

votes
1

answer
337

Views

How to combine a slider with an animation?

Using matplotlib.animation and matplotlib.widgets (sliders and buttons), I wanted to create an animated simulation of a distribution (starting from a sample and ending in a big one), which takes as input from the user the parameters of the distribution using widgets. This is my code: import matplotl...
1

votes
1

answer
70

Views

Python matplotlib - Large Window on Linux

Simple Question, how do I set matplotlib to display a fullscreen window? Here is the code for doing it on Windows... mng = plt.get_current_fig_manager() mng.window.state('zoomed') Which works fantastic... on Windows. I'm using Linux, and it does not work there, only allowing the following window.sta...
Conrad Selig
1

votes
1

answer
605

Views

How can I change the x-axis index date format in matplotlib?

My code below outputs the following image: from datetime import datetime as dt import matplotlib.pyplot as plt from matplotlib import style import pandas as pd import pandas_datareader.data as web import os start = dt(2017, 1, 1) end = dt.now() df = web.get_data_yahoo('AAPL', start, end, interval =...
NaN
1

votes
0

answer
50

Views

How to make a velocimeter-style plot in Python?

This is what I'm going for: velocimeter Is there anything in, say, matplotlib that can achieve this? I've looked at the matplotlib gallery but couldn't find anything that looks like it.
marco_gorelli
1

votes
0

answer
129

Views

matplotlib.dates loadtxt converters date conversion python 2

i am using juypter notebook and python 2.using matplotlib.dates I am unable to access the date def bytespdate2num(fmt,encoding = 'utf-8'): strconverter = mdates.strpdate2num(fmt) def bytesconverter(b): s = b.decode(encoding) return strconverter(s) return bytesconverter Date,Open,High,Low,Close,A...
1

votes
0

answer
148

Views

Efficiently plotting large number of pictures on a grid in Python

I've implemented a program that outputs a very large number of tiny images next to each other in a certain way. Currently I'm using a grid of 50x50 but I want to be able to increase this and my current code becomes really slow in that case. I've read from several people online this is because of the...
user3343378
1

votes
1

answer
64

Views

matplotlib wrong line placement mlines.Line2D [duplicate]

This question already has an answer here: Matplotlib Line2D unexpected behavior 1 answer I am trying to get a simple lineplot, between point pairs. This function is supposed to add each line seperately to the plot. def newline(p1, p2): ax = plt.gca() l = mlines.Line2D(p1, p2) ax.add_line(l) return...
artie
1

votes
1

answer
45

Views

Struggling formating xticks with DateTime from Pandas Dataframe

I'm currently struggling with my xaxis format.. the date doesnt start at 2017 but somewhere in the year 1138. Is there something I've done wrong? my tick labeling should be like Thu 01.06.2017, Fri 02.06.2017, etc. %pylab inline import matplotlib.pyplot as plt import pandas as pd import matplotlib.d...
Mario
1

votes
0

answer
86

Views

How do I get pandas to plot in interactive mode?

I've managed to get it working with this code: %env DISPLAY=:20 import matplotlib.pyplot as plt plt.switch_backend('Qt5Agg') # %pylab import numpy as np t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2*np.pi*t) plt.plot(t, s) plt.xlabel('time (s)') plt.ylabel('voltage (mV)') plt.title('About as simple...
cjm2671
1

votes
2

answer
120

Views

Align specific x labels differently to each other?

I am working on this plot: Conceptually, would like to change x labels position from this: to this: Is there a function for that? Do I need to manually change the position of my label and if so how? I don't want to use : plt.margins(x=0.04) because it shifts my data as well, and I need, just 2006 sh...
Charlotte
1

votes
0

answer
47

Views

python matplotlib OHLC error

The purpose of this code is to plot a csv file which contains 7 columns ['Date', 'Time', 'Open', 'High', 'Low', 'Close', 'Volume'] into candlesticks chart OHLC. I began with parsing the Date Time as single thing, then defining it as index. Here is the code: import pandas as pd import matplotlib.pyp...
Sayed Gouda
1

votes
0

answer
256

Views

I'm trying to add Matplotlib to python 3.7 but I get this error message as show in the picture attached. Does anyone know a solution?

I'm trying to add Matplotlib to python 3.7 but I get this error message as show in the picture attached. Does anyone know a solution?
Luciano Hendricks
1

votes
1

answer
85

Views

I can't install matplotlib, error message says ModuleNotFoundError: No module named 'html.parser'; 'html' is not a package

I followed the instructions from this site, but when I get to this step: Copy the .whl file to your project folder, open a command window, and navigate to the project folder. Then use pip to install matplotlib: This error message appears: Traceback (most recent call last): File 'C:\Users\myname\AppD...
huhu
1

votes
1

answer
17

Views

Can I set labels for subplots simultaneously?

I have several axis in a subplot which require some of the same labels. I was hoping I could simply map the feature to the axes by fig, ax= plt.subplots(ncols= 10, nrows = 10, figsize = (20,10)) *Plotting Commands* map(lambda x: x.set_ylabel('Value'), ax) This doesn't seem to work, but there are no...
Demetri Pananos
1

votes
1

answer
222

Views

Batch job fails when using matplotlib [duplicate]

This question already has an answer here: _tkinter.TclError: no display name and no $DISPLAY environment variable 6 answers I try to execute the following simplified batch job on my linux machine: [email protected]:~/Test_plots# ls batch_job.txt plot.py [email protected]:~/Test_plots# more plot.py import matplot...
Andy
1

votes
1

answer
102

Views

Updating Matplotlib subplots with images in Jupyter/Python 3

I have a function, modified from an external source, that takes a list of images and displays them on a grid within a Jupyter notebook (python 3). def show_images(images): images = np.reshape(images, [images.shape[0], -1]) fig = plt.figure(figsize=(28, 28)) gs = gridspec.GridSpec(28, 28) gs.updat...
Novak
1

votes
0

answer
113

Views

Export jupyter notebook with matplotlib images without inline

I would like to export a jupyter notebook to html or ipynb to display online (e.g. Github). My notebook produces some images with matplotlib, and I would like a static version of these images to be included. I've seen several examples of this, and they all seem to use the inline option: %matplotlib...
tiago
1

votes
1

answer
95

Views

tiny border in librosa.display.specshow

I want to draw a spectrogram of a song to be used as feature for image classification with convolutional neural networks. Therefore, the output image must be as clean as possible, without any labels/axes/ticks etc. From various sources, i have managed to disable the border that matplotlib would dra...
bmurauer
1

votes
1

answer
88

Views

Savefig error with hist2d and unequal bins

I have been trying to make a 2d histogram, but kept coming up with an error with savefig. The error only seems to arise when using bins of unequal size in hist2d. Has anyone any insight? Here is a simple code that replicates the fault: import matplotlib.pyplot as plt import numpy as np # This works...
Phil
1

votes
0

answer
3k

Views

Import Error: Cannot import name '_path' PYTHON

I know other people went through this kind of problem but I still can't fix the problem. I just began to programming. I use spyder IDE and get the following error when I run the code. File 'C:\Users\kaany\AppData\Roaming\Python\Python36\site-packages\matplotlib\path.py', line 25, in from . import _...
Kaan Yilmaz
1

votes
0

answer
197

Views

Matplotlib draw function not working

I'm trying to use matplotlib.pyplot to view a video as I process the frames. The code below displays a plot window, but the images are never drawn. import cv2 import matplotlib.pyplot as plt class Viewer: def __init__(self, video_filename): self.cap = cv2.VideoCapture(video_filename) self.ax1 = pl...
noel
1

votes
0

answer
175

Views

I know you can use a for loop to create multiple plots with matplotlib, but can you also use the loop to embed the figures into a gui?

I was just wondering if there is a way to also create a loop of embedded plot figures. Right now I am using a for loop to create multiple separate plot windows. So I was hoping I could use a similar for loop to create the figures and embed them in a GUI i am making. Also if anyone is familiar with P...
dengel1392
1

votes
1

answer
238

Views

Animated Line Graph with Matplotlib/Python [duplicate]

This question already has an answer here: matplotlib animated line plot stays empty 3 answers I'm having trouble getting my line graph to animate. Background: I'm working on a program that will handle simulating network latency and I'm trying to graph the latency so I can see how well my program is...
Bryan Davis
1

votes
0

answer
59

Views

Running multiple python scripts to plot data in parallel

I'm looking for some advice as to how to organise a python project. I have a directory ./scripts containing several python scripts as below: . ├── plot.py ├── __init__.py └── scripts └── __init__.py └── sinx_1.py └── sinx_2.py └── sinx_3.py Each of these scr...

View additional questions