Questions tagged [matplotlib]
Matplotlib is a plotting library for Python, built on NumPy and often used interactively with IPython. Its compact "pyplot" interface is similar to the plotting functions of MATLAB®.
179 questions
6
votes
1
answer
3k
views
Computing the autocorrelation between 2D time series arrays in python
I have a list of 2D arrays which comes from a time evolution PDE (in \$(x, y, t)\$) that I solved numerically. There are \$k\$ arrays, which all have the same dimensions, and the arrays correspond to ...
7
votes
1
answer
830
views
Calculating relay operating times, according to IEC 60255
The script below is used to determine relay operating times, as defined in the standard IEC 60255. The equation and relevant information can be found here.
...
2
votes
1
answer
165
views
Pythonic way of managing data for plotting 2D variance plots
I have collected large dataset of trajectories in 3D space. Below is the information about dataset-
Each trajectory (shape: n x 4) is saved into CSV file with the following header: ...
3
votes
1
answer
499
views
Trigonometric Subplots with Matplotlib
The code consists of 4 functions that result in a figure with 3 subplots:
a sine wave
a cosine wave
and the superposition of both (a bichromatic wave).
I have shown in 4 ways, the first two are ...
1
vote
1
answer
722
views
Comparison of exponential smoothing and regression on a Lloyds bank's stock price data
What is one way to change it into a program that makes use of OOP concepts? I have always programmed this way and I feel that I would somehow need to improve on it. By the way, I have deliberately ...
6
votes
1
answer
339
views
Probability of event using Central Limit Theorem + plotting results
I've been doing a Udemy course called: "Statistics for Data Science" and I decided to solve one of the homework with Python to kill two birds with one rocket #elon.
The task was:
The team of ...
12
votes
1
answer
889
views
Live-streaming tweets and plot its sentimental value in colors on a world map
I want to have someone reviewing and helping me get some good ideas in how to improve my current project.
All information about the project is in the following github link.
I would also appreciate ...
6
votes
1
answer
136
views
Separate scrap and production by area
I'm looking for feedback on things that can be streamlined in each section. The data it creates is all needed whether it's used in a graph or not so I can't get rid of anything, just combine steps ...
8
votes
1
answer
1k
views
Ramachandran plot (plotting the torsion angles of protein backbone)
I would like to have some insights on the code I created. It would be really insightful for me to get some feedback about the code, what I should do differently, if there is an easier, more elegant ...
5
votes
1
answer
313
views
Image processing and plotting
I wrote a program for analyzing pictures. The problem I'm having is very slow processing time for medium images like 800x800. I think the root of the problem for this is the ...
6
votes
1
answer
2k
views
Plotting text from a dictionary with Matplotlib
I have the following dictionary:
...
14
votes
1
answer
12k
views
Farthest point algorithm in Python
I am learning Python and I tried to do a program to find K points from a set of N points, farthest as much as possible (I'm not ...
6
votes
1
answer
1k
views
3-D plot of rectangular surface using matplotlib
I have made a 3D mesh. See below:
And the code below:
...
2
votes
1
answer
238
views
Python: Print matrices as figure
I have very large data files (10 to 40 GB) which I want to plot as figures. A data file contains t matrices of size n x ...
7
votes
1
answer
9k
views
Show weekly and daily variations in time-series data
I've got some time-series data. I want to examine the weekly and daily variation of that data. For weekly data I can make a plot like this, with the days along the horizontal axis:
For daily data I ...
3
votes
0
answers
3k
views
Reading a csv file and making a histogram in Python using NumPy and Matplotlib
I have written the following code which reads a csv file that contains a bunch of words and their sentiment value. Words like abandon may have a value of -1, while words like progress and freedom have ...
3
votes
1
answer
121
views
Time-dependent state machine with two outputs
Given a class BasicDataFeed whose purpose is to feed questions and answers into an artificial neural network, which is tested in a non-negotiable manner as follows:
...
6
votes
1
answer
3k
views
Solver for some simple tangrams
I decided to write a program to solve Tangram puzzles. This went a bit out of hand and I ended up with 600+ lines of code. I don't think it should have taken so much code.
Here is an image of a ...
4
votes
1
answer
2k
views
Histogram output from parse of json-ish data in python
The idea is exploratory data analysis, the output rendered as a histogram to get an idea of relative frequency of records:
The example data set looks like this:
...
4
votes
1
answer
361
views
Increase Matplotlib performance of redrawing
I have written an error analyzer in Python for the product of our company.
I want to read the log from our device and parse it, On Y axis there are different components of the device, and on X axis ...
18
votes
1
answer
7k
views
Plot timings for a range of inputs
When writing Code Review answers, it becomes often necessary to measure how long the modified code takes vs how long the OP's code takes. I needed a nice way to visualize this as a function of the ...
13
votes
1
answer
1k
views
Plotting polynomials roots
NOTE: See follow up to this question here
I created a simple python script to plot quadratic, cubic and quartic polynomials with integer coefficients between -4 and 4. It uses numpy to find the roots ...
2
votes
2
answers
5k
views
Euler Method Harmonic Oscillator
I have written very simple Python code to solve the simple harmonic oscillator using Euler method, but I am not sure if the program is correct or not. I would be very grateful if anyone can look at my ...
5
votes
1
answer
9k
views
matplotlib get_legend_handles_labels always return empty
I have a problem when adding elements to the same figure.
The problem is with the legend.
At each iteration I add elements and the corresponding legend.
But I want the legend to include all the ...
2
votes
0
answers
2k
views
Applying Model-View-Controller to Tkinter/matplotlib Application
I'm a novice programmer. I am preparing to refactor a large project of mine to follow a model/view/controller design pattern, with separate modules for each (and eventually separate modules for the ...
2
votes
1
answer
364
views
Create boustrophedon path in Matplotlib
I have following code that creates parallel swathes of specified sizes. Can someone suggest a better way of doing this?
...
5
votes
1
answer
338
views
Plot president's approval rating of president with lowest approval rating by day of presidency
I was curious which U.S. president had the lowest approval rating for each day in their presidency. For example, which president had the lowest approval rating on day 42, and what was the rating. I ...
6
votes
2
answers
149
views
MCMC Metropolis Hastings for German Tank Puzzle
I have implemented the following Markov chain Monte Carlo MCMC
algorithm for the German tank puzzle found here.
I just want to make sure everything is legit and that I am not getting the right answer ...
3
votes
1
answer
175
views
Reaching the philosophy wiki page - Follow Up
This is a follow up to my original post:
I've written a class that will start from a random Wikipedia page, then choose the first link in the main body, and then navigate following the links until ...
3
votes
1
answer
166
views
Reaching the philosophy wiki page
I've written a class that will start from a random Wikipedia page, then choose the first link in the main body, and then navigate following the links until it finds the Philosophy page. When I run the ...
2
votes
1
answer
3k
views
Function Plotter GUI in Tkinter and Matplotlib
I have been working on plotting time varying functions in Python as my most recent project, and would love input on optimization, proper Tkinter form, and anything that stands out like a sore thumb.
...
3
votes
1
answer
3k
views
Coordinates of 2D points zoomed in/out
This might be a simple issue that I am overcomplicating, but I've spent quite some time reading about polygon scaling and I've come to the conclusion that it is not precisely what I need.
Given a set ...
15
votes
1
answer
6k
views
Time-scrolling interface in matplotlib
I've create a simple interface for viewing a time-series as it changes over time in matplotlib. You can pause, reset or click/drag on the time-line to change the view. Have I used the matplotlib API ...
2
votes
1
answer
887
views
Estimating Pi with random darts on dartboard - high complexity issues
I've been trying to write nice snippet of code to simulate pi estimation by randomly throwing darts on a dartboard. While running the following code on high but reasonable numbers my mac doesn't plot. ...
12
votes
1
answer
9k
views
Plotting a rectangular prism
I'm creating a rectangular prism function, whose output looks like this:
I think that this code can be improved by optimizing the use of np.meshgrid with a Python ...
6
votes
0
answers
2k
views
Plotting the Mandelbrot set at different zoom levels [closed]
I'm interested in making an animated movie of a zoom in on a part of the Mandelbrot set. My code works well for a few zooms, but upon trying to zoom in quite far, I find that the fractal becomes "...
-4
votes
1
answer
8k
views
Python PID simulator controller output [closed]
I have written a piece of code (in Py3) that graphs out the controller value of PID controller. This is so that by changing the various sub controllers (P/I/D) I can visualise how the graph changes. I'...
3
votes
2
answers
961
views
Real time graph simulation of dice tossing
When tossing a dice many many time all numbers tend to appear the same number of times, but if the number of throws is small then some numbers may appear more or less often than others, even ...
5
votes
1
answer
108
views
Plotting some displays from a weather URL
I've got some code that plots some displays from a weather URL and locations in a CSV file. I'd like to see if anyone can make the code more efficient, the code runs fine without any errors and I'm ...
4
votes
1
answer
4k
views
Barrier Option Pricing using Python
This is my implementation of pricing an exotic option (in this case an up-and-in barrier option) using the Monte Carlo simulation in Python. I use NumPy where I can. Any ideas to optimize this code?
<...
4
votes
1
answer
187
views
Trello list scraper with data visualization - Monthly food expenses
For the last couple of months I've been working on a python script that pulls data from a specific Trello list and sums up the numeric values by list (lists are split up into months). I've worked on ...
12
votes
3
answers
642
views
Plotting different parameterized polynoms
For a university assignment I had to plot different polynomial functions depending on one single parameter. That parameter gave the number of supporting points to interpolate a given function in the ...
4
votes
1
answer
198
views
Abstract graphing-and-timing functions
I like to use timeit to measure performance of small, and sometimes big, functions. However it can be uncertain as to what the 'actual' time to execute the function ...
3
votes
3
answers
6k
views
Plotting from a Pandas dataframe
I want to improve my code. Is it possible to get the plot without repeating the same instructions multiple lines?
The data comes from a Pandas' dataframe, but I am only plotting the last column (...
5
votes
1
answer
386
views
Read in file, filter out records, output results
I have been working on a project for some time and have let one Python file grow into a huge file that tries to do everything. The structure is pretty flat, and I don't like it. I've used other ...
5
votes
1
answer
2k
views
Multigeneration evolution simulator, graphing phenotypic change
I created an evolution simulator. It takes random chance and applies it to phenotypes of species. This was very much for fun, and I would love any input on:
Readability of code
Efficiency of ...
3
votes
2
answers
13k
views
Plot heat map from csv file using numpy and matplotlib
There's a csv file with format:
x0, y0, v00
x0, y1, v01
...
x1, y0 v10
...
And what I want to do is to plot a heat map, in which at location (x, y) the value v ...
3
votes
1
answer
2k
views
Scoreboard with score evolution plots using classes
I've very recently started using OOP paradigms for the code in my work (academic research). As an exercise I tried coding this quick scoreboard.
I'm not interested in improving the 'display' part, I ...
5
votes
1
answer
2k
views
Evaluating a series of Legendre polynomials
The following function represents the electrostatic potential, in spherical coordinates, due to a ring of charge \$q=1\$ and radius \$R=1\$, placed in the plane \$x\$-\$y\$:
$$\phi(r,\theta) = \sum_{...
8
votes
2
answers
13k
views
Histogram of a string
I'm teaching myself Python and when a friend posted this sentence
Only the fool would take trouble to verify that his sentence was
composed of ten a's, three b's, four c's, four d's, forty-six e's,...