Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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®.

4
votes
0answers
34 views

graphtimer v2 - Utility to plot timings

GitHub repo (MIT) Clone the repo and replace the contents of example.py with the one at the bottom and you'll have everything setup. Explanation of the code A ...
8
votes
1answer
47 views

Python implementation of approximating the chance a particle is at a location after n steps in the cardinal directions

Recently, I became very interested in a probability practice problem in my textbook for my class. I decided to implement it in code and I think I got most of it implemented. Right now, I'm hoping to ...
5
votes
1answer
62 views

Code to plot graphs with multiple panels efficiently

I quite often plot graphs looking at how some property or function varies with different parameters. Normally, I find the analysis code can be written fairly succinctly and separated into a suitable ...
5
votes
1answer
159 views

A Python script to plot data and save to PDF

I have a very simple Python script. All it does is open two data files from a given directory, read the data, make a series of plots and save as PDF. It works, but it is very slow. It takes almost 20 ...
1
vote
1answer
40 views

Plot a piecewise-defined function

I would like to plot the following function: $$ \begin{align} \Lambda(\delta\tau) &\equiv\ \chi(\delta\tau, 0) = \frac{1}{T_i} \int_0^{T_i} a(t_0+t')a(t_0+t'+\delta\tau) dt' \\ &= \begin{...
2
votes
1answer
113 views

Generating scatter plot from a CSV file

Assume you have the following data in the form of a csv-file. The content looks something like this: ...
2
votes
0answers
64 views

Sum, validate, and plot monthly inventory levels

The idea is that I have a subset of the movements of material of a factory (over 700k rows), and I want to separate these movements by the reference of each product to plot the stock of each product ...
4
votes
1answer
60 views

Project structure for a reactor model built in Python

I use Python for various computational reactor modeling activities. While there are many components to the models I develop, the basic structure of the project folder tends to be similar to the ...
2
votes
0answers
27 views

Modularizing matplolib graphing based on a data dictionary

For plotting I often use a dictionary that contains my data of interest, regarding my numerical simulations. For example I have a numpy array let's call it ...
2
votes
1answer
48 views

Implementation of a threshold detection function in Python

I want to implement following trigger function in Python: Input: time vector t [n dimensional numpy vector] data vector y [n dimensional numpy vector] (values correspond to t vector) threshold tr [...
1
vote
0answers
45 views

Live plot with many subplots

I have a stream of sensor data which I want to visualize in a plot with many subplots. Plotting the data is a real bottleneck in my code. Right now I get with small resolution only 16 FPS which is far ...
5
votes
0answers
34 views

Measure size of repository as a function of time

In order to avoid having to make any real progress (at least for a short time), I wrote a script that measures how much progress I have made so far, instead. Specifically, this script sums up the file ...
2
votes
0answers
60 views

GUI to control a NZXT cooling and lighting system

I am working since a couple of weeks on my first Python application and I would love to have a review of the code I wrote so far. The app has the purpose of controlling the cooling and lighting of an ...
2
votes
0answers
31 views

Function that plots data frames, supporting several variants

I defined a function that generates tables and creates countplots and barplots based on the arguments that it receives. But the snippets of code inside the function are repeated several times, which ...
3
votes
1answer
85 views

Centered finite difference approximation for edge enhancement

I implemented a centered finite difference approximation for edge enhancement in images. The difference approximation has a step size h of the partial derivatives in the x- and y-directions of a 2D-...
3
votes
1answer
45 views

Create histogram with greater than symbol in x axis in pyplot

I wanted to create a histogram from a list of positive integers. I want to bin it so that I show all single numbers, say K through N, with more than k elements in the data set, as well as the number ...
3
votes
1answer
408 views

Plotting quadratic equations with varying parameters

On Wikipedia, there is a graph shown: It shows the quadratic \$y = ax2 + bx + c\$, varying each coefficient separately while the other coefficients are fixed (at values a = 1, b = 0, c = 0) As a ...
2
votes
1answer
44 views

Regularised regression code

I wrote some code to do regularised linear regression and it works, but I don't like the fact that I've had to double call the functions when plotting, nor the fact that I've sliced those calls to get ...
4
votes
1answer
41 views

Plot random generated 'n' non-colliding circles using Matplotlib

I have a function which plots n randomly generated non-colliding circles. The circle is a Circle object, part of ...
3
votes
0answers
50 views

Data set generation with Python and Matplotlib

I want to use Python and Matplotlib to create a data set of images. I want to do this by transforming the plot to a numpy matrix. At the moment it takes about 0.1 second to generate 100 images of size ...
3
votes
0answers
202 views

Time distribution of Twitter data

The tweepy.models.Status class creates a 'tweet' object, it has attribute .created_at which is the posting time of the tweet in ...
7
votes
1answer
364 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 ...
6
votes
1answer
107 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
1answer
60 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
1answer
100 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
1answer
626 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 ...
5
votes
1answer
162 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 ...
10
votes
0answers
604 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 ...
3
votes
1answer
67 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 ...
4
votes
0answers
383 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 ...
6
votes
1answer
167 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 ...
5
votes
1answer
903 views

Plotting text from a dictionary with Matplotlib

I have the following dictionary: ...
11
votes
1answer
2k 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 ...
3
votes
0answers
446 views

Python, matplotlib, 3d plot, how to make this code effective, light, fast?

I have already make a 3D mesh. See below: And the code below: ...
2
votes
1answer
56 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 ...
6
votes
1answer
3k 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
0answers
2k 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 ...
2
votes
0answers
50 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
1answer
636 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 ...
3
votes
1answer
474 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: ...
2
votes
0answers
165 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 ...
16
votes
1answer
1k 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 ...
11
votes
0answers
729 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 ...
1
vote
1answer
2k 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 ...
1
vote
1answer
1k 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 ...
1
vote
0answers
1k 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
1answer
136 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
1answer
258 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 ...
2
votes
0answers
43 views

MCMC Metropolis Hastings for German Tank Puzzle

I have implemented the following 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 by chance. ...
3
votes
1answer
108 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 ...