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

Filter by
Sorted by
Tagged with
-4
votes
0answers
26 views

How to add an interactive plot in Jupyter Notebook? [closed]

I have made a plot for the basic SIR model. I am satisfied with my plot, however, I would like to be able to have an interactive slider that tweaks my parameters beta and gamma. I would like both of ...
2
votes
0answers
14 views

Getting Graph and Block Animation to Run Smoothly Together

I have been working on some code that produces a live graphic of a graph and blocks moving. It works in theory but does not look like how I want. The animation runs very slow when showing both the ...
3
votes
1answer
88 views

matplotlib fixing axis scale and alignment

There is few points In the script I don't like I think it can be improved, but I need a second opinion, here is the interactive plot I'm trying to build. here is the code with thought in comments. <...
4
votes
1answer
154 views

Jupyter notebook style help + code suggestions for pandas

I wanted to open source some code to scrape and analyze publicly-filed stock buys and sells from U.S. senators. I'm not familiar with code style for Jupyter notebooks or pandas in general. Would it be ...
2
votes
0answers
24 views

Profiling for Bézier curve calculations

Recently I posted an answer on a question about Bézier curve calculations. As a micro-synopsis: there are three implementations of De Casteljau's algorithm here, including the original poster's, AJ ...
-2
votes
1answer
56 views

This code demonstrates the central limit theorem. Is this code “Pythonic”?

I am new to Python, so I am interested in knowing if I am efficiently using python for this project. This program is meant to simulate the Central Limit Theorem. It uses sliders to adjust the number ...
3
votes
1answer
80 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 ...
5
votes
1answer
130 views

Tkinter GUI for running HPLC pumps, real-time data visualization

What I made I used Tkinter to write a GUI to run some HPLC pumps for my work. The application sends some messages to the pumps via serial connections, reads a response, then logs data to a csv file. ...
1
vote
0answers
2k 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? <...
0
votes
0answers
23 views

Generate a ColumnDataSource for a bokeh histogram hover displaying the names of the units in each bar

I came up with the following setup_cds function as a solution to my own SO question. My question is: how could I improve it (especially the joining of the names ...
12
votes
1answer
5k 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 ...
3
votes
1answer
115 views

Plotting the integer values in text format in matplotlib piechart

I have done a clustering algorithm and represented the results in a pie chart as shown below. ...
2
votes
1answer
148 views

Forex Simulator in Python using pandas and matplotlib

Description: This would make a first part of a currency exchange simulator The first phase includes downloading currency historical data from histdata.com api, plotting given period and given time ...
6
votes
1answer
203 views

Animation of sorting algorithms

I have created a visualisation of sorting algorithms using tkinter and matplotlib. Please let me know what you think and if you have any suggestions or find errors. The aim of this code is to create ...
8
votes
3answers
632 views

Modifying Titration Data analysis results

This is my first script that I've written. As a result, I'm sure there are extra lines that are unneeded, or maybe better more concise ways of doing things than I have done here. I have tried to add ...
1
vote
0answers
36 views

Basic peak editing with matplotlib

Usually I have really noisy datasets, so peak detection is quite hard to do just with coding. However the human brain immediately sees what is just random noise. I decided to make a basic peak editing ...
3
votes
1answer
49 views

Plot timings for a range of inputs MkII

To celebrate questions getting more reputation points per upvote, I revisited my previous question, Plot timings for a range of inputs. Since the time of that original question (more than two years!),...
4
votes
1answer
84 views

Automating a set a of weekly reports, including graphs and delivery of reports

I have been writing code to automate some weekly reports. I had help over on Stack Overflow. I have code that works for the most part, however there are a few things that I just can't seem to fix. In ...
5
votes
1answer
688 views

Plotting shapely polygon in matplotlib

When working with geometric objects I like working with the shapely module (Shapely - PyPI). In here it is easy to create polygons and define union, intersection and differences. Like so: ...
12
votes
2answers
837 views

Python Sound visualizer

The past week I have tinkered making a sound visualizer using Tkinter, Matplotlib, NumPy, PyAudio and using a thread to be able to play the sound and to display the plot at the same time. I have been ...
2
votes
1answer
128 views

Binary file reading and plotting data

This code reads binary file. Read data is converted into signed values and gets plotted if the user wants it. Data looks as below: ...
10
votes
1answer
268 views

Predator-prey simulation

I made a random-walk predator-prey simulation that focuses on individual animals instead of the (maybe) more common array-based approach. I'd like to hear your opinion about this: how could the ...
6
votes
1answer
176 views

Schelling's model of Segregation Python implementation with Geopandas

If you don't know what is Schelling's model of segregation, you can read it here. The Schelling model of segregation is an agent-based model that illustrates how individual tendencies regarding ...
12
votes
1answer
814 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 ...
2
votes
0answers
34 views

Matplotlib realtime monitor

I would like to share a matplotlib real-time monitor plot that I needed for another application. Basic trick is to reverse the time, so that t=0 is now and t=20 is twenty seconds in the past and to ...
3
votes
0answers
179 views

Double pendulum real time plot

Double Pendulum I made a little application that embeds a matplotlib dynamic plot into tkinter that enables control through the ...
3
votes
0answers
219 views

Simple Kivy App for Bootstrap Algorithm

I have a very simlpe app built using Kivy, for performing bootstrap algorithm (statistics). We must input some samples in the form x1,x2,...,xn (these will be ...
1
vote
0answers
32 views

Parsing and plotting with numpy (or pandas)

I am trying to improve the following code to make it more broadly applicable and quick to use. ...
13
votes
1answer
960 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
0answers
129 views

Matplotlib embedded in tkinter

Investigating how to use tkinter controls with buttons and sliders and to combine these with matplotlib, I have come to the following code. Suggestions for improvements and tips are most welcome. ...
3
votes
0answers
340 views

Converts audio files to fixed size chunks and the chunks to spectrogram images

This code takes in input as audio files (.wav or .WAV) and divides them into fixed-size (chunkSize in seconds) samples. Then these chunks are converted to spectrogram images after applying PCEN (Per-...
3
votes
0answers
95 views

Animation of an incremental rotary encoder

While reworking my teaching materials for an exercise of an introductory course on mobile robotics, I recently created a animation/simulation of an incremental rotary encoder, e.g. often used for ...
3
votes
1answer
97 views

Calculating pi via collisions

This code calculates pi via collisions; it asks for a user input of N which determines the mass of the second block. It is fully working, it just takes forever to run when N >= 2. I want to be able ...
6
votes
1answer
539 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 ...
5
votes
0answers
79 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
56 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
76 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 ...
1
vote
1answer
70 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{...
4
votes
1answer
116 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
1answer
630 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
72 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 ...
2
votes
0answers
68 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
247 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
115 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
42 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 ...
3
votes
0answers
307 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
38 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
145 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
277 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
3k 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 ...