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

120 questions
Filter by
Sorted by
Tagged with
193 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 ...
1k views

### Plotting text from a dictionary with Matplotlib

I have the following dictionary: ...
4k 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 ...
558 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: ...
75 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 ...
5k 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 ...
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 ...
56 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: ...
979 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 ...
657 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: ...
214 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 ...
2k 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 ...
905 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 ...
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 ...
3k 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 ...
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 ...
182 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? ...
278 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 ...
46 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. ...
129 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 ...
69 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 ...
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. ...
2k 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 ...
4k 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 ...
507 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. ...
4k 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 ...
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 "...
6k 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'...
737 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 ...
71 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 ...
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? <...
129 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 ...
500 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 ...
125 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 ...
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 (...
139 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 ...
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 ...
11k 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 ...
1k 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 ...
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_{...
6k 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'...
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 ...
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) ...
710 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 ...
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 ...
4k 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 ...
234 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: ...
202 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? ...