iteratively creating graphs - linux

I have a bunch of files containing x and y coordinates, representing time and value (space-separated, but can be amended)
For example, in each file I will have this sort of points:
15:06:59 0.0140
15:07:00 0.0142
...etc....
I want to create a word file (or some equivalent) to show all these graphs.
Currently, I am using Excel. It pretty daunting task, as I have to plug paste numbers in two rows for each graph, and I have many of them, both graphs and points
Thanks

Maybe create a TEX file and then compile it to the PDF?
Great example of creating line plots in TEX here: http://www.texample.net/tikz/examples/line-plot-example/
Beside TIKZ there is also second package that allows you to create graphs programmatically: the PGF plots

The word "iteratively" in the question title makes me think that you want to have a look at RRDTool.

I did something like this before, my solution was to write a C program that wrote all of these values into a CSV file format. Then simply use a CSV to .xls file converter.

you could use the gnuplot program. This will allow you to produce charts using scripts and save them as images. It's pretty good and aimed specifically at producing charts.
alternatively you could try the R package - this is a full statistical analysis package and will produce lovely charts but it's got a substantially steeper learning curve than gnuplot

Related

how to create timelines that have multiple streams that merge and fork off each other?

I found this image / solution online. the source is included. it's a template that uses draw.io to create multiple timelines that look like merged code.
we have many projects that look like this. does anyone know how to do this programmatically in Excel.
The goal is to be able to manipuale the a program with data to generate this timeline.
any help is awesome.
ok - so after reaching out to couple of folks / reading online - I am going with using excel line graph with really large markers
and so, I get the following type. I am going to play with style and see if I can make the straight lines into curve lines
I can now overlay text as key markers.
thanks

How can I edit a DXF in node.js?

I'd like to make a custom lasered label from a user's input on a website. I have a template dxf file and I'd like to replace placeholder text with the user input. My problem is the dxf file format is very unreadable in its text format. Is there any way to make sense of the numeric data? If not are there any other formats (svg, etc) that would be easier to work with?
EDIT: The reason I've found it unreadable in terms of text is that the program (Solidworks) converted the text to curves.) At this point I'm trying to figure out how to prevent that.
AutoDesk was nice enough to document DXF syntax in great detail. Spend a couple hours understanding the documentation from the link below, and I think you will find it quite easy to parse and edit using code.
To just replace some placeholder text, it should be just as simple as reading the DXF file into a string (a dxf file is no different than a txt file), performing a text replace operation and saving it back to file. Just make sure that your placeholder text is very unique and is not contained in any of the key words in the document below (otherwise your DXF file will get corrupted). Something like "PlaceHolderText" will do the trick.
http://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf
Edit: More Info
I do a lot of work with AutoDesk Inventor which is in direct competition with SolidWorks, so they are effectively the same tool. We were faced with a similar problem of needing to place text onto sheet metal flat pattern DXFs that came out of Inventor in order to identify the part, but Inventor simply could not do it (see, exactly the same!). One of our developers had the idea to place a very precise geometry punch onto the flat pattern. After the DXF was generated he wrote some code that parsed the DXF file and replaced the geometry with a text entity. More specifically we used a triangle with sides having each length defined to something like the 7th decimal place. You can then use one of the vertices of the triangle to position the text, including rotation. This process would be automatic, so once you write the code with the help of the document above (which won't take the long), it will just work. If your engraver can handle text the way you want it, I'd say this is a very good solution. We generate hundreds of parts every day using this code. Hope this helps.

add a duplicate (hidden) text layer to a pdf for extra searching

My problem:
I have a pdf with lots of roman characters with complex diacritical marks (e.g., ṣ, ś, ṝ, ǎ, etc.). To make it easier to search within the pdf, I would like to add an additional layer, much as one does with hocr, where the same text is present without the diacritics.
When using full-text search engines I can index multiple terms at the same position (vector) - I would like to achieve the same effect here.
I have read lots about adding a hocr layer to scanned images, but I really just want to duplicate the text layer, pass it through a script that strips the diacritics (straightforward enough) and then adds it back in as a hidden but searchable layer.
Anyone have any suggestions? (Solutions involving any platform, language, library or toolchain will be useful!)
Thanks :)
Edit: please let me know if the question is unclear.
Well I have a (slightly ugly and hackish) solution, so I thought I'd share it.
I'm using PDFMiner to extract the text, along with the co-ordinates. Then I'm using ReportLab to write the normalized versions of the text to a new pdf, in exactly the same position, as hidden text. To make the positions line up properly, I found I had to use exactly the same font, so I've used a combination of FontForge and MuPDF to extract the required font(s) from the original pdf.
Finally, having created the new pdf, I'm using pdftk to merge it with the original.
It works pretty well, but has the downside that copying text out of the pdf results in the normalized text being copied too. But this is acceptable for my present purposes, and I can't see any way around it. The pdf spec. doesn't really support my objective, and so I don't imagine I can do better than this hackish solution.
I have written something similar to add searchable text by OCR'ing images and converting it to PDF in C#. I used QuickPDF from www.quickpdf.com to create hidden white text objects on top of the image and this worked reasonably well.
In your case QuickPDF would allow you to extract the text strings along with bounding boxes and font details. You could then normalize your text and create the invisible text objects using the existing font and position information and then save it out to a new file.
This would basically give you the same PDF as you have now and also give you both the original and normalised text as you are getting now.
QuickPDF is a commercial library. If your solution works well for you then there is no used buying a commercial engine though. The nice thing though is that it only requires 1 SDK and you would look at it if you had a more than a few PDF's to convert.

beamer includegraphics with screenshots

I'm using the LaTeX-Beamer class for making presentations. Every once in a while I need to include screenshots. Those graphics are pixel-based, of course. I use includegraphics like this:
\begin{figure}
\includegraphics[width= \paperwidth]{img/analyzer.png}
\end{figure}
or usually something like this:
\begin{figure}
\includegraphics[width= 0.8\linewidth]{img/analyzer.png}
\end{figure}
This leads to pretty bad readibility of the contained text, so I'm asking for your best practices: How would you include screenshots containing text considering, that I will do the output PDF with pdflatex?
EDIT: I suppose I'm looking for something like an 1:1 presetation of the image within beamer. However, [scale = 1.0] doesn't achieve what I'm looking for.
Your best bet is to scale the image outside of Latex for inclusion, and include it in 1:1 ratio. The scaling done by graphics packages in Latex isn't going to be anywhere near as good as possible from other tools. Latex (Tex) has limited floating-point arithmetic capabilities, whereas an external tool can use sophisticated algorithms to get the scaling better.
Another option is to use only a part of the screenshot, the one you want to concentrate on.
Edit: If you can change the font size before taking the screenshot, that's another option—just increase the font size for the screenshots.
Of course, you can combine the two methods.
I have done exactly what you do and e.g defined
\newcommand{\screenshot}[1]{\centerline{%
\includegraphics[height=7.8cm,transparent]{#1}}} % 7.8in
which worked with whatever style I was using at the time. The files included with this macro were all PNGs created with one the usual Linux screen capture tools.
Edit: You may have to play with the size (height and width) of your input files. It came out rather nice for me (and this was from a presentation in 2006).
How about scaling it as follows:
\includegraphics[scale=0.5]{images/myimage.jpg}
This works for me.
Have you tried to convert the image to .eps or .pdf file and use this file in LaTeX?
Maybe try also latex, dvips and ps2pdf.
Problem might be in used viewer, in Linux I use Document viewer or ePDFViewer and output is much worse than in Adobe Reader or Acrobat, which I use in Windows...

Getting R plots into LaTeX?

I'm a newbie to both R and LaTeX and have just recently found how to plot a standard time series graph using R and save it as a png image. What I'm worried about is that saving it as an image and then embedding it into LaTeX is going to scale it and make it look ugly.
Is there a way to make R's plot() function output a vector graphic and embed that into LaTeX? I'm a total beginner in both so please be gentle :) Code snippets are highly appreciated!
I would recommend the tikzDevice package for producing output for inclusion in LaTeX documents:
http://cran.r-project.org/web/packages/tikzDevice/index.html
The tikzDevice converts graphics produced in R to code that can be interpreted by the LaTeX package tikz. TikZ provides a very nice vector drawing system for LaTeX. Some good examples of TikZ output are located at:
http://www.texample.net/
The tikzDevice may be used like any other R graphics device:
require( tikzDevice )
tikz( 'myPlot.tex' )
plot( 1, 1, main = '\\LaTex\\ is $\\int e^{xy}$' )
dev.off()
Note that the backslashes in LaTeX macros must be doubled as R interprets a single backslash as an escape character. To use the plot in a LaTeX document, simply include it:
\include{path/to/myPlot.tex}
The pgfSweave package contains Sweave functionality that can handle the above step for you. Make sure that your document contains \usepackage{tikz} somewhere in the LaTeX preamble.
http://cran.r-project.org/
The advantages of tikz() function as compared to pdf() are:
The font of labels and captions in your figures always matches the font used in your LaTeX document. This provides a unified look to your document.
You have all the power of the LaTeX typesetter available for creating mathematical annotation and can use arbitrary LaTeX code in your figure text.
Disadvantages of the tikz() function are:
It does not scale well to handle plots with lots of components. These are things such as persp() plots of large matricies. The shear number of graphic elements can cause LaTeX to slow to a crawl or run out of memory.
The package is currently flagged as beta. This means that the interface or functionality of the package is subject to change if the authors find a compelling reason to do so.
I should end this post by disclaiming that I am an author of both the tikzDevice and pgfSweave packages so my opinion may be biased. However, I have used both packages to produce several academic reports in the last year and have been very satisfied with the results.
Shane is spot-on, you do want Sweave. Eventually.
As a newbie, you may better off separating task though. For that, do this:
open a device: pdf("figures/myfile.pdf", height=6, width=6).
plot your R object: plot(1:10, type='l', main='boring') -- and remember that lattice and ggplot need an explicit print around plot.
important: close your device: dev.off() to finalize the file.
optional: inspect the pdf file.
in LaTeX, use usepackage{graphicx} in the document header, use
\includegraphics[width=0.98\textwidth]{figures/myfile} to include the figure created earlier and note that file extension is optional.
run this through pdflatex and enjoy.
You might want to consider using Sweave. There is a lot of great documentation available for this on the Sweave website (and elsewhere). It has very simple syntax: just put your R code between <<>>= and #.
Here's a simple example that ends up looking like this:
\documentclass[a4paper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\begin{document}
\maketitle
In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:
<<>>=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
#
which shows that the location parameter of the Ozone
distribution varies significantly from month to month. Finally we
include a boxplot of the data:
\begin{center}
<<fig=TRUE,echo=FALSE>>=
boxplot(Ozone ~ Month, data = airquality)
#
\end{center}
\end{document}
To build the document, you can just call R CMD Sweave file.Rnw or run Sweave(file) from within R.
This is a dupe of a question on SO that I can't find.
But:
http://r-forge.r-project.org/projects/tikzdevice/ -- tikz output from r
and
http://www.rforge.net/pgfSweave/ tikz code via sweave.
Using tikz will give you a look consistent with the rest of your document, plus it will use latex to typeset all the text in your graphs.
EDIT
Getting LaTeX into R Plots

Resources