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
2
votes
1answer
2k 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
149 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
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 ...
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
124 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
1answer
63 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
1answer
2k 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
1answer
1k 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 ...
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 ...
2
votes
1answer
445 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
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 ...
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
1answer
5k 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
2answers
652 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
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 ...
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? <...
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 ...
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 ...
3
votes
1answer
120 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
3answers
5k 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 (...
3
votes
0answers
138 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
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 ...
3
votes
2answers
10k 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
1answer
986 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
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_{...
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'...
2
votes
2answers
46 views

Run several Python programs and check for errors

For a post-graduate subject that I present, I maintain a repository of examples (on GitHub) from the textbook which is contributed and edited by my students, who are not very Python literate. I have ...
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
640 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 ...
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 ...
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 ...
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: ...
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? ...
14
votes
1answer
485 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 ...
2
votes
1answer
1k views

Generic plotting wrapper (around matplotlib)

I am experimenting with making my own re-usable libraries. Therefore, I decided to start with some of the plots that I generally use during development/debugging to check what is actually inside my ...
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 ...
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 ...
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 ...
13
votes
2answers
715 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 ...
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 ...
3
votes
2answers
159 views

Calculating doubling times from data points

In the code below, noisy data points with unique errors are created. From this, an exponential function is fitted to the data points, and then doubling times (10 unit windows) are calculated. I'm ...
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 ...
3
votes
1answer
1k views

Drawing a cloud of points

I decided that it would be nice to write some code to draw a cloud of points. Of course my first thought was to draw some random points but the result is not cloud-ish, it is well... random. In the ...
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 ...
1
vote
1answer
398 views

Linear regression with visualization

I have created a small script that: Creates a lot of random points. Runs a small brute force search to find a rect that has a low error, that is a good fit for the data. Runs a linear regression on ...
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 ...
1
vote
1answer
2k views

Colorbar for Matplotlib 3D patch plot

I am trying to make a 3D grid plot in Python using Matplotlib. The grid consists of hexahedral cells (with qudrilateral surfaces). The surfaces should be colored according to their height, that is: ...