You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contents/plotting/plotting.md
+36-4Lines changed: 36 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Plotting
2
2
3
3
Plotting is an essential tool for visualizing and understanding important details of several algorithms and methods and is necessary for studies in various areas of computational science.
4
-
For many languages, such as python, julia, and matlab, it is relatively straightforward to create simple plots for various types of data; however, for several other languages, like fortran, C/C++, and java, plotting can be a chore.
4
+
For many languages, such as python, julia, and matlab, it is relatively straightforward to create simple plots for various types of data; however, for several other languages, like Fortran, C/C++, and java, plotting can be a chore.
5
5
Because the Algorithm Archive strives to be language agnostic, we do not want to favor any particular set of languages and have decided instead to output all data that needs plotting into a file format that can easily be read in by various plotting scripts separate from the algorithm implementations.
6
6
7
7
If you are implementing any algorithm in a language found on this page, you should be able to modify your existing code to allow for on-the-fly plotting.
@@ -485,7 +485,7 @@ In the case of two-dimensional image output, the data file be similar, but this
485
485
486
486
[import](data/2d_sample_low_res.dat)
487
487
488
-
It is expected that the number of columns does not vary in each row and that we are working with an $$n \times m$$ matrix which can be simply plotted as a series of pixels that scale in color according to some defined colorbar.
488
+
It is expected that the number of columns does not vary in each row and that we are working with an $$n \times m$$ matrix which can be simply plotted as a series of pixels that scale in color according to some defined color bar.
489
489
490
490
{% method %}
491
491
{% sample lang="gnuplot" %}
@@ -503,7 +503,7 @@ splot "sample_data.dat" matrix with image
503
503
504
504
{% endmethod %}
505
505
506
-
#### changing the colorbar
506
+
#### changing the color bar
507
507
508
508
For plotting images from data files, we will often need to specify how we color the image by setting a custom color bar
509
509
@@ -537,7 +537,7 @@ For the purposes of the Algorithm Archive, this space is mainly two-dimensional;
537
537
We will update this section if three-dimensional scatter plots are required.
538
538
539
539
For the purposes of the Algorithm Archive, scatter plot data will be output as a series of $$x$$ and $$y$$ pairs, where each row has an $$x$$ and a $$y$$ value, separated by a tab character.
540
-
For example, a datafile might look like this:
540
+
For example, a data file might look like this:
541
541
542
542
[import:1-10](data/scatterplot_data.dat)
543
543
@@ -561,6 +561,37 @@ Here, we have chosen `pointtype 7`, simply because it is easier to see when comp
561
561
562
562
{% endmethod %}
563
563
564
+
# Histograms
565
+
566
+
Many different algorithms will output data as a series of points that must be organized into separate bins before anyone can make sense of the data.
567
+
For example, here are 10 values from a set of 100 randomly generated integers between 1 and 9:
568
+
569
+
[import:50-60](data/rand.dat)
570
+
571
+
Someone might ask, "How many 1s show up in this string of numbers?"
572
+
Similarly, someone might want to know how many 1s we have *in comparison* to the number of 2s (or 3s or 4s, etc).
573
+
To do this, we would create a set of bins and then iterate through the data, adding one to a bin every time we find a corresponding number.
574
+
Note that the bins do not necessarily need to be sequential integer values and that for floating point numbers, the input might need to be rounded.
575
+
You can even histograms objects or anything that else that can be categorized.
576
+
577
+
For the data that we have shown above, we might create a histogram that looks like this:
For this, we are using a fill style to use with `fillsteps` so the histogram is colored, but if you just want a line, you could remove the fill style and use `histeps` instead.
590
+
As another note, we are using `t 'data' smooth frequency`, which essentially turns the input numbers into a small, binned array to plot.
591
+
{% endmethod %}
592
+
593
+
Note that this code rounds the input in the case of floating point numbers.
594
+
564
595
If you are interested in seeing this type of plot generate fractal patterns, please look at the chapter on [iterated function systems](../IFS/IFS.md).
565
596
566
597
## Conclusions
@@ -607,6 +638,7 @@ The text of this chapter was written by [James Schloss](https://github.com/leios
607
638
- The image "[gnuplot_2d_sample](res/gnuplot/2d_sample.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
608
639
- The image "[gnuplot_2d_sample_colorbar](res/gnuplot/2d_sample_cb.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
609
640
- The image "[gnuplot_scatterplot](res/gnuplot/scatterplot.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
641
+
- The image "[gnuplot_histogram](res/gnuplot/histogram.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
0 commit comments