Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/gnuplot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSurya Bhupatiraju <surya95@gmail.com>2016-12-08 03:24:47 +0300
committerSurya Bhupatiraju <surya95@gmail.com>2016-12-08 03:24:47 +0300
commitacaf8ef3e67a18b96a7acdb238ac0dd456ad8b37 (patch)
treeabd7451baba8bd53c3b30af1bfa1c924d3173a62
parent1badc6af7835e85f42ce4cef6e3ef09f477e92a3 (diff)
Add example of using gnuplot.raw() to label points in docs
-rw-r--r--doc/common.md29
-rw-r--r--doc/plot_labels.pngbin0 -> 17849 bytes
2 files changed, 28 insertions, 1 deletions
diff --git a/doc/common.md b/doc/common.md
index b63801d..7ee2c63 100644
--- a/doc/common.md
+++ b/doc/common.md
@@ -96,4 +96,31 @@ gnuplot.axis{0,13,0,''}
gnuplot.grid(true)
gnuplot.title('London average temperature')
```
-![](plot_raw.png)
+![](plot_raw.png)
+
+We can show another example of its usage by labeling data points. Here, we generate two clusters of data with two Gaussian distributions, write it to a text file in three columns of (label, x_coor, y_coor), and plot the points with labels.
+
+```lua
+labels_tab = {}
+for i=1,20 do
+ table.insert(labels_tab, math.ceil(i/10))
+end
+x = torch.cat(torch.Tensor(10):normal(2, 0.05), torch.Tensor(10):normal(3, 0.05), 1)
+y = torch.cat(torch.Tensor(10):normal(2, 0.05), torch.Tensor(10):normal(3, 0.05), 1)
+
+file = io.open('gaussians.txt', 'w')
+io.output(file)
+for i=1,20 do
+ io.write(string.format('%d %f %f\n', labels_tab[i], x[i], y[i]))
+end
+io.close(file)
+
+gnuplot.pngfigure('plot_labels.png')
+gnuplot.title('A Tale of Two Gaussians')
+gnuplot.raw("plot 'gaussians.txt' using 2:3:(sprintf('%d', $1)) with labels point pt 7 offset char 0.5,0.5 notitle")
+gnuplot.xlabel('x')
+gnuplot.ylabel('y')
+gnuplot.grid(true)
+gnuplot.plotflush()
+```
+![](plot_labels.png)
diff --git a/doc/plot_labels.png b/doc/plot_labels.png
new file mode 100644
index 0000000..5687174
--- /dev/null
+++ b/doc/plot_labels.png
Binary files differ