25
votes
Accepted
Remove points in a straight line
A look at the second plot in the post shows that something has gone wrong. There are four points in a line here:
This shouldn't be possible, since "points that create a straight line when plotted" ...
14
votes
Accepted
Sorting algorithm visualizer in C++ and SDL2
In all, this is a nice program. In particular, it compiled and ran (almost) flawlessly on Linux, so keep up the good work on portability! Here are some things that may help you improve your program.
...
10
votes
Accepted
Speech Recognition Part 1: Generate Training Data
I have to admit that I have no idea what the purpose of the code is (never worked with speech recognition) but I know a little bit Python so I can give some advise on the code itself.
Performance
...
10
votes
Remove points in a straight line
You can use Ramer Douglas Peuker algorithm. RDP takes a curve and eliminates points that are close to straight lines. It is distance based. Starting with the two endpoints, it forms a line and picks ...
10
votes
Accepted
Chart showing the Percentage of Answered CR questions
When I ran your script and started digging through the dom, I noticed that Apr 21 12:00 AM was missing -- I wonder why that was.
Anyhow, I wanted to encourage ...
10
votes
Accepted
An ASCII histogram of a die rolled n times
The roll function generates a random sequence of integers. The loop body shows me that you know how to seed a pseudo-RNG with a true source of randomness but you're ...
9
votes
Reverse Engineering Data Files (Binary Visualization)
It seems the program overwrites pixels each time it processes a chunk
this means wasting 2*MAP_SIZE*...
8
votes
Query to plot a histogram of song ratings
It would be better to use GROUP by in your SQL. By this way you will get rid of long SQL query.
...
8
votes
Reverse Engineering Data Files (Binary Visualization)
I will be mostly focusing on performance. All benchmarks are done using the time commands on an 2018 MacBook Air (8GiB) using a 32MiB PDF file. I will be computing ...
7
votes
Accepted
Plotting polynomial roots with density
Keeping all else untouched, this gives a 1000× performance boost:
...
7
votes
Speech Recognition Part 1: Generate Training Data
PyAudio doesn't seem to have a with interface, however you should add that interface to your class. PEP 343 explains why it was added to Python, but it mostly comes ...
7
votes
Accepted
Displaying programming languages on a timeline
First of all, congratulations, the result looks really good and that's a lot of work for an exercise! I particularly like how you frequently used standard algorithms.
That is also quite a lot of code ...
7
votes
Accepted
draw_circle Template Function Implementation for Image in C++
You’re ensuring, inside the loop, that you’re not outside the image on the right and bottom, but not on the left or top (x or y ...
6
votes
Accepted
Reading and processing histograms stored in ROOT files
Given both the documentation of Python 3 contextlib or contextlib2, I’d say your usage is pretty standard for the tools at play.
However, there is something bothering me a bit in your code:
...
6
votes
Accepted
D3js: transition from stacked bar chart to bar chart with different datasets
Before dealing with the "enter", "update" and "exit" pattern, which is specific to D3, I'd like to address some general issues first.
Do not mix jQuery and D3: this mix is normally unnecessary. Not ...
6
votes
Accepted
Genetic Sequence Visualizer - Generating large images
Parser
Your parser has a bug in line 62:
raw = ''.join([n for n in file.readlines() if not n.startswith('>')]).replace('\n', "").lower()
will ...
5
votes
Plotting polynomial roots with density
Use what C++ provides
If you use the C++ versions of the headers:
...
5
votes
Accepted
Drawing a regression line with a timeseries
You don't need dfc, dfc.sort_index() and dfc.sort_values(time_col_str) both make a copy of ...
5
votes
Accepted
Plotting an input curve and its FFT using gnuplot in C++
Firstly, does the program give correct results?
If so, how do you know?
Without going into extensive unit testing, checking your results against a Matlab prototype/your Python implementation is ...
5
votes
Accepted
Showing two d3.js charts on the same page
I don't see anything wrong with the approach you're using, which is changing the variables' names and writing the code as a whole piece. The reason for that is simple: you have two fundamentally ...
5
votes
Accepted
Predator-prey simulation
Shebang
#!/opt/anaconda3/bin/python
This is suspicious. Usually you should just
#!/usr/bin/env python
and make sure that ...
5
votes
Accepted
Draw a 2d graph using slashes
Some simple things:
top and length could probably have better names (Top of what? Length of what?), maybe ...
5
votes
Compute and plot a 2D vector field with radial symmetry in Python
Is there a suitable plotting function allowing to avoid to compute and store the two potentially large arrays u and v, and ...
5
votes
Reverse Engineering Data Files (Binary Visualization)
Very interesting approach to create a pattern for reverse engineering. I remember a similar plot (3D actually) done to the timespan between two heartbeats. The normal plot looked like a cigar-shaped ...
5
votes
Accepted
Midpoint Circle Algorithm Implementation for Image in C++
You have a serious bug. Each loop iteration draws 8 pixels. If one of those pixels fails a bounds check, you skip the entire loop iteration. Correct behavior is to draw the other 7 pixels as normal. ...
4
votes
Git Insert Delete Graph
Overview
It is great that you:
Used strict and warnings
Leveraged other people's code by using the CPAN modules
Used comments ...
4
votes
Print the frequency of characters as a horizontal histogram
You have assumed that the input character coding is ASCII, but the C standard allows other codings (notoriously EBCDIC) that use different numbers for the printable characters.
Even with only ASCII-...
4
votes
Data Explorer query that makes bar graphs
I'll answer your main questions:
Can I refactor it so that the list of when like then statements occurs only once? (Preferably without complicating the code too much.)
Yes, but not at the expense of ...
4
votes
Remove points in a straight line
This is not really a code review, but an alternative approach to solving your problem.
I did my doctoral thesis on bicriterion fitting of polylines to noisy data series. The two criteria are the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
data-visualization × 154python × 58
performance × 25
javascript × 24
matplotlib × 20
beginner × 18
histogram × 16
python-3.x × 14
r × 13
numpy × 12
pandas × 12
c++ × 11
c × 11
statistics × 10
java × 8
graph × 7
image × 7
d3.js × 7
ascii-art × 6
csv × 5
c# × 4
object-oriented × 4
haskell × 4
random × 4
simulation × 4