Plotting with Torch7


Gnuplot is a cross-platform command-line oriented graphing application. It can plot everything : 2D, 3D pictures. The API exist since 1986, thus it is kind of robust! Lua Wrappers are good and easy to use for most of basic figures. However, advanced features requires to be familiar with gnuplot interface. Charts can be saved in a large range of format from png to eps. One of the major drawback of Gnuplot is its lack of interactivity. If you are now willing to play with web API, then, it is worth learning the gnuplot command-line options (I wish you good luck :P).



Some tricks to know:

  • $> killall gnuplot_x11  will be your best friend
  • The method gnuplot.imagesc is very useful to plot activation units over mini-batch. It is hard to implement it


3 Comments on “Plotting with Torch7

  1. Great,
    I would like to ask if there is a way how to compute Recall and precision from a confusion matrix and draw them if it is possible. I am facing this problem for more than a month but I could not find an answer. So, please help.

    • Sure!
      First, you can compute your confusion matrix my using the optim package:

      Then, if you want to plot accuracy/recall upon time, Dygraph/Display is a good library

      For every steps:
      – Compute the Precision/Recall from your confusion matrix
      \text{Precision}=\frac{tp}{tp+fp} \,
      \text{Recall}=\frac{tp}{tp+fn} \,

      – Plot it !

      Lua code:

      local labels = {"epoch", 'accuracy', 'recall'}
      local data = {}

      local config =
      title = "Global accuracy/recall upon time",
      labels = labels,
      ylabel = "ratio",

      for t = 1, noEpoch do

      local accuracy, recall = someFct()

      table.insert(data, {t, accuracy, recall })

      -- display = disp.plot(data, config)


      • Hi
        Many thanks for replying but I try it many times but did not work with. Could you please give me more intuition about the code.

Leave a Reply

Your email address will not be published.