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
16
votes
1answer
3k 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 ...
15
votes
3answers
4k views

Orbital Trajectory simulator

I have written a simple program to do trajectory simulation in the Earth-Moon system, it still has a long way to go I am working on making it more class oriented and am looking into implementing a ...
15
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 ...
14
votes
3answers
469 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 ...
14
votes
1answer
488 views

Racetrack plotter

My Racetrack is just that. A Racetrack. You can't race it (yet) because I had trouble with collision detection, but I wanted to share it anyway. It creates a base polygon by using ...
14
votes
1answer
797 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 ...
13
votes
2answers
716 views

Numerics for a game theory calculation using expected utility

I am trying to replicate Bruce B. de Mesquita's (BDM) results on political game theory for prediction. Based on where actors stand on issues, their capabilities, salience, BDM's method attempts to ...
12
votes
1answer
12k views

Time and temperature displaying program for Raspberry Pi

This program displays either the time, current temperature, 12hr graph of temps, 24 hr graph of temp or a week's graph of temps. Selection is based on user input of one of the GPIO pins. Please ...
12
votes
1answer
3k 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 ...
12
votes
1answer
570 views

A big “Game of Life”

Our quest: Create a big simulation for Conway's Game of Life, and record the entire simulation history. Current Approach: Cython is used for an iterate method. The ...
11
votes
1answer
3k 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 ...
11
votes
1answer
2k views

Modified Taylor diagrams

There is a type of diagram summarizing how well predictions from numerical models fit expectations; one obvious use case is comparing machine-learning regression models. Modified Taylor diagrams are ...
10
votes
2answers
3k views

Predator Prey Simulation

Below is a simple random walk predator prey simulation that is optimized to the best of my abilities. I would love to hear about any improvements that can made. ...
10
votes
1answer
292 views

Visualize Parts of Song as Analyzed by Echonest

This is the a bit of code that works with Echonest API's pyechonest and remix libraries combined with matplotlib.pyplot to offer a simple visual representation of the start and end "parts" of a music ...
10
votes
0answers
675 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 ...
8
votes
2answers
2k views

Python program to check if a set of points is at land or at sea

I have written a program that divides an geographical area up in cells with size 0.002 degrees longitude by 0.001 degrees ...
8
votes
1answer
48 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 ...
7
votes
1answer
2k views

Optimizing very simple piece of “Game of Life” code by taking advantage of NumPy's functionality

Here is the code as it stands right now: ...
7
votes
2answers
5k 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'...
7
votes
1answer
97 views

Outputting scatter plots [closed]

I have written a python function that outputs scatter plots using Matplotlib after processing the data a little. It works but it's painfully slow. I was wondering if anybody had any suggestions as to ...
7
votes
1answer
523 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
3answers
227 views

Energy curve plotter

I am not much experienced in Python, just write some small script. All my codes are procedural. They work fine, and I always check them with pep8. One of them is: ...
6
votes
1answer
179 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 ...
6
votes
1answer
124 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. ...
6
votes
1answer
175 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
2answers
171 views

Covering array scraper and sorter

A covering array is an \$N \times k\$ array in which each element is a from a set of \$v\$ symbols, and for every \$t\$ columns, every possible set of \$v^t\$ choices of the symbols appears at least ...
6
votes
1answer
743 views

Prepare data for a contour plot with matplotlib

My question concerns the following Python code which is already working. As far as I have seen, there are very elegant solutions of compacting code. Do you have any ideas on how to make the following ...
6
votes
1answer
747 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 ...
6
votes
1answer
4k 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 ...
5
votes
2answers
276 views

Social network evolution

I am writing a piece of code which models the evolution of a social network. The idea is that each person is assigned to a node and relationships between people (edges on the network) are given a ...
5
votes
1answer
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_{...
5
votes
1answer
1k views

Matplotlib: Display y value as a marker

I created a plot on which the y value is visible with the marker. What's your opinion ? I wonder if I could have done something simpler. (code should run in a Jupyter notebook) ...
5
votes
1answer
125 views

Charting daily balance

I have been trying my hand at Python lately. I have been able to look at code examples and create a custom application that queries a Microsoft SQL Server, pulls out two columns (date, balance) and ...
5
votes
1answer
176 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 ...
5
votes
1answer
1k 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 ...
5
votes
1answer
641 views

Web crawler that charts stock ticker data using matplotlib

I've built a web crawler using the BeautifulSoup library that pulls stock ticker data from CSV files on Yahoo finance, and charts the data using ...
5
votes
1answer
264 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 ...
5
votes
1answer
65 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
958 views

Plotting text from a dictionary with Matplotlib

I have the following dictionary: ...
5
votes
1answer
70 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 ...
5
votes
1answer
3k views

A matplotlib scatter function inside a for loop

This function is working exactly as I want, only, it's taking too long. For speed ups, I've tried to do as much as I can before the main for loop by declaring ...
5
votes
0answers
35 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 ...
5
votes
0answers
498 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
0answers
1k views

Plotting the Mandelbrot set at different zoom levels

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
2answers
176 views

Python object-oriented pipe cooling simulations

Here is my code simulating liquid in a pipe cooling under different conditions. How did I do approaching this in an object orientated way? Is there any way I can improve this code? ...
4
votes
2answers
2k views

Matplotlib-venn and keeping lists of the entries

Having come upon the wonderful little module of matplotlib-venn I've used it for a bit, I'm wondering if there's a nicer way of doing things than what I have done so far. I know that you can use the ...
4
votes
1answer
46 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 ...
4
votes
1answer
79 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 ...
4
votes
1answer
125 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 ...
4
votes
0answers
51 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 ...