Showing posts with label plots. Show all posts
Showing posts with label plots. Show all posts

Friday, November 18, 2016

Papeeria News, Nov 18: updated Plot Builder

TL;DR: edit plot data and styles in a convenient table interface; use Plotly or Gnuplot to build plots

Updated Plot UI

We have upgraded the user interface of our Plot Builder. The builder has been somewhat hidden until today; now it goes much more visible with rich UI for editing data files and for tuning plot appearance. Check out the new "Table" tab in the editor when you open csv files!

All plots from the project are easily accessible from the new Plots pane. You can scan through the produced images, open Plot Builder from the Plots pane or create new plot files. 

Plot Builder UI, Plots Pane and Viewer pane showing the compiled plot


Integration with Plotly

In addition to Gnuplot engine, those who are registered on great Plotly service can now use Plotly to build plots. Switch between Gnuplot and Plotly using "Build Plot" dropdown in the Plot Table UI.

Saving generated files to the project

Last, but not least: you can now save any file which appears in the preview pane into the project. Plots are saved automatically, and if you want to save a PDF with the compiled paper, you can do it with "Save" dropdown in the Viewer pane.

More docs are available on Papeeria Documentation pages.

Friday, December 5, 2014

Using Plot Builder in Papeeria

This help article describes how to use plot building tool.

Scenario

Suppose you've got some data and you want to build a histogram and insert it into your paper. Let's take oil production stats as an example
Country                "Production (mln bbl/day)""  "Share of World \\%"
"Saudi Arabia"         11.7                         13.80 
"United States"        11.1                         13.09
Russia                 10.3                         12.23
China                  4.3                          5.15
Canada                 3.8                          4.54
Iran                   3.5                          4.14
Iraq                   3.4                          3.75
"United Arab Emirates" 3.08                         3.32
Venezuela              3.02                         3.56
Mexico                 2.9                          3.56
Oil production data taken from Wikipedia

Adding a plot

Adding a plot into LaTeX document involves a few steps: one needs to create a plot itself and then insert a plot into the text as a figure. In Papeeria you can do all this stuff quickly: place caret where you want to add figure tags, hit Alt+Insert and choose Insert Plot from the context menu.
Insert Plot dialog

Paste your data into the text area, choose file name where data will be saved to, choose column delimiter and optionally figure caption. Click Done and Papeeria will add data file into the project, compile PDF file with a histogram and insert figure tags at the caret position.
Hint: choose column delimiter appropriately and quote values which contain delimiter substring (especially important when delimiter is whitespace)
Month   "Price in Euro"
2012-01 86.2344
2012-02 89.7464
2012-03 94.2123
2012-04 91.3811
2012-05 86.0061
2012-06 76.4181
2012-07 83.3615
2012-08 90.4529
2012-09 87.9202
2012-10 85.5900
2012-11 84.8372
2012-12 82.7839
2013-01 84.1874
2013-02 86.7123
2013-03 84.1555
2013-04 79.3453
2013-05 79.2452
2013-06 78.3375
2013-07 81.8711
2013-08 82.5541
2013-09 83.0109
2013-10 79.9776
2013-11 80.0078
2013-12 80.7921
2014-01 78.7576
2014-02 79.4208
2014-03 77.7698
2014-04 78.1769
2014-05 79.4203
2014-06 82.2801
2014-07 79.9469
2014-08 77.5741
2014-09 76.4254
2014-10 69.4637
2014-11 64.3892
Oil price data from
European Central Bank web site

Live preview

When data file is opened in the editor, it is possible to preview the compiled plot by ticking "Show plot preview" checkbox. We refresh plot in the preview as you type. If it fails to compile because of error in data or some other reason, we show a cached plot.

Plot settings

Cogs icon above the editor with opened data file provides access to plot settings pane. You can change plot style, data columns delimiter, position legend appropriately, define axis names, change ticks format and rotation. Most of the options are quite simple, with tics label format being the most tricky. Please refer to gnuplot docs to learn about format specifiers. At the moment we take tic labels for X axis from the first column in the data file.

Plot settings pane and live preview

Advanced plotting

Behind the scenes we compile plots with gnuplot and xelatex. Users of free Epsilon plan don't have many tuning options, however, customers who are subscribed to paid plan Delta have access to raw gnuplot scripts and can enjoy almost all gnuplot features.

Let's build a graph of oil price changes and tune it a little bit. Quick plot created with Insert Plot action looks as shown below. We want to make X tic labels less dense, change colors and line style a little bit and add a dashed line at the mean value of oil prices.

Initial oil prices plot

So let's start with exporting our plot to gnuplot script. Click Export script button, choose script file name (it is important keep .gnuplot extension) and location and leave Use as input checkbox switched on to feed your data to the generated script. Open the generated .gnuplot file in the editor and paste the following code. We hope comments in the code are explanatory enough.

# Code generated by the plot builder
set datafile separator whitespace
set key autotitles columnhead bottom left
set style data linespoints
set style fill solid 1.0
set format x "%g"
set xtics rotate by -30
set format y "%g"
set ytics rotate by 0
set xlabel "Date"
set ylabel "Price in Eur"

# Calculating mean value using constant fitting function
f(x) = mean_y

# '<&3' takes input from the file with descriptor number 3. 
# If you checked "Use as input" checkbox when you
# generated a script then your data file will be associated with this descriptor.
# If you have another data file in your project and want to use it here,
# you may just use relative file name
fit f(x) '<&3' u 0:2 via mean_y

# Placing label on the plot. Yes, you can use LaTeX!
set label 3 gprintf("Mean =$\\frac{\\Sigma_i price_i}{N} = %g$", mean_y) at 1, 65

# required to enable dashed line types 
set termoption dash

# blue-ish solid with width 2 and small round shaped dots
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 pointtype 7 pointsize 1

# keywords can be abbreviated:
# red-ish dashed width 2, dots undefined
set style line 2 lc rgb '#dd181f' lt 2 lw 2

# this function returns non-empty string with the value of column number "labelcol"
# for every fifth value of column countcol (0 is the column with ordinal numbers of
# the rows in the dataset)
everyfifth(numcol, labelcol) = (int(column(numcol)) % 5 == 0) ? stringcolumn(labelcol) : ""

# Plot our data using line style 1 (defined above) and mean function
# using line style 2
plot '<&3' using 0:2:xtic(everyfifth(0, 1)) ls 1, f(x) ls 2

Papeeria tracks edits in both data and script file and in a few moments it will recompile the plot. The result is much more appealing:

Oil prices plot after tuning

Now we can go back to our text and compile it. Figures are already there, we may need to adjust their placement using optional argument of the figure environment and enjoy the result.

LaTeX in plot labels

Plot labels are compiled with xelatex, so you can use maths and other LaTeX features.
Hint: you need to double-escape with backslash symbols which carry special meaning to LaTeX, such as percent symbol (see the first data sample above)

Connecting data files and script files

You may want to create different scripts and choose which one to use to process your data file in the plot settings pane. You can also link a few data files to the same script, and they will recompile automatically when you change the script file.

Help on gnuplot

Admittedly gnuplot is not the easiest plotting system. If there is an issue with your script and gnuplot writes something to the log, we'll show it in the log pane. However, sometimes log records may not be very helpful. If you're struggling with gnuplot scripts, here is a short list of useful links:

Known limitations and future work

At the moment being plots don't play well with project versions and project clones. We are working on this and will fix the issues shortly.

We plan to enhance plot builder capabilities and add other plotting systems. Don't hesitate to file tickets to our bug tracker or uservoice!

Want to stay in touch?

Follow us on Twitter: http://twitter.com/Papeeria
On Google+: http://google.com/+Papeeria
and VKontakte: http://vk.com/papeeria

Love Papeeria? We need your feedback!

We'll appreciate if you take a few minutes of your time and write a review on our Google Web Store pages. Any language is okay and no flattering is required. Just be honest!


Friday, May 30, 2014

Papeeria News, May 28

TL;DR: insert plots easily; get notified about what you collaborators do; get closer to real-time editing

Plot builder

In the end of winter we launched a simple plot builder. It was pretty dumb and the only thing it could do was to build a histogram from CSV file. Now it is way more configurable. You can choose between a few types of 2-D plots, specify axis labels, tick label formatting and legend position. And with handy wizards you can insert a plot into your paper in just a few seconds.

How to start
Suppose you decided to insert a plot into this slide. All you have is a CSV file. What shall you do?

TODO: plot here


You could use a template "Simple line chart or histogram", but there is a faster way, which adds a CSV file, generates image and insert LaTeX markup simultaneously. Just position your caret where you want to insert a plot and hit Alt+Insert (or Cmd+N if you're on Mac). Choose Insert Chart... from the context menu and specify desired file name, figure caption and paste CSV data in a dialog window.

Chart wizard

Click Done ...and your plot is done. Recompile your project to see the result.

TODO: plot here Done!

Plot tuning
The plot is ready, but you may need a line chart or some other type of chart, and labels for axis. Open a CSV file which we've created from your CSV data and click cogs icon over the editor. In the plot settings pane you can tune a few parameters. Click Apply and we'll rebuild the plot, and if you check Show preview you will see it in the viewer pane.



Notifications

If you have collaborator in your project, you may want to be notified about their changes. We now have a notification widget which shows you the recent file updates, if any, and the authors who did the updates.
Нотификации

Real-time editing...

... is not yet completely done, but we're almost there.

We're still using file locks, and when someone is editing a file, the remaining collaborators can only read that file. But now they will see the edits in real-time. We're launching real-time collaborative editing soon. Stay tuned!

Friday, February 21, 2014

Papeeria News, Feb 21

We're so busy with hacking that forgot about our birthday. One year ago, on Feb 12, 2013, we produced our first noise and started receiving HTTP requests from the external world.

We have been just a LaTeX editor throughout this year, but we have always been dreaming about space invasion something bigger. In our latest update, Papeeria v20, we do the first steps towards enhancing our borders.


Build plots automagically

Experiments and results representation is arguably the most important part of scientific work. The world is waiting for a picture or a graph where a curve with your results looks better than other curves. There are rich and interesting ways of building plots in LaTeX, but many people may not have time or will to learn them, and just insert graphs from Excel.

We can help you a little bit. If you create a CSV file in your project and fill it with data, like this:

# Scalability benchmark of a few NoSQL databases
# Read-mostly worlkoad
Shards, Cassandra, HBase,   MongoDB
1,      624.31,    206.06,  115.47
2,      1091.83,   318.18,  183.03
4,      2608.90,   433.89,  298.69 
8,      5000.98,   784.60,  746.26
16,     10016.62,  1467.96, 1006.41
32,     19277.25,  2969.33, 1575.21

then we automatically create a histogram plot as PDF image next то your source file. You can use standard LaTeX ways to insert image into your document. Look at the result in our demo project or test plots in your own project by using "Simple line chart or histogram" template.

Plot template
At the moment being we don't provide any tuning capabilities. It is histogram only, you can't choose colors or fonts and so on. But stay tuned, it is just the first step.

Figure assistant

By the way, about images and figures. When you need a figure in your document, you need to type a few lines of code and if you're using online editor, upload image file to the server. Now you can use Figure assistant which shows up on hitting Ctrl+I in the editor. It uploads image file and then inserts figure environment and include \includegraphics and \caption commands.


Figure assistant


Instant project structure updates

If you have played with plots already you may have noticed that PDF file appears in the project pane automatically. No refresh required. We're working on real-time collaboration and this important part is already public: now we instantly send project structure updates to all project collaborators. If Bob creates a new file, it appears in Alice's workspace instantly, and should Alice rename a folder, Bob will see the changes automatically.


Bugfixes

We have fixed a few bugs with mobile version and with cached compile results. In particular, if you compile project with pdfLaTeX, we will remember it and will automatically choose this engine wherever you use Papeeria.