I want to draw a couple of simple bar plots to include in a LaTeX document.
For some reason (unless im missing something), there doesn't appear to be a simple way to generate bar plots in LaTeX.
I could of course generate them in Excel and save them as PDF, but I'd rather have the flexibility of doing them dynamically in LaTeX.
I looked into TikZ, but it seems nobody on the interwebs is using it for a measly barchart (which is what I need it for), and the code below generates a barplot without any axis:
\begin{tikzpicture}[scale=2]
\draw[ycomb, color=gray,line width=0.5cm]
plot coordinates{(1,1) (2,2) (3,3)};
\end{tikzpicture}
What do you use? Am I doing something horribly wrong?
I'd say you want pgfplots: this is built on top of Tikz as a proper plot-drawing interface.
I do not know if you're familiar with gnuplot, that can generate bar plots. There is a "TikZ terminal" (something that outputs TikZ-code) for gnuplot, however, as far as i know, you have to compile it yourself in order to get it working.
I think there's also another "LaTeX terminal" generating pstricks (?) code or something similar.
Can I point you towards Asymptote (Wiki, Gallery). You can make professional looking graphs offline from LaTex processing, but being LaTeX aware. It is a full blown C-ish language for vector graphics and function graphing. The output eventually is encapsulated postscript (eps) which can be displayed directly into LaTeX documents.
Related
Today I've decided to learn about writing LaTeX posters. I want to ask if tcolorbox is the right place to focus my effort in creating poster sections.
Here's why I'm asking. The first thing I tried was the package fancybox and the shadowbox environment. As long as I had white background, that looked nice. However, when I changed the background color of the poster and I came to realize that the background color of a shadowbox object is not customizable. In the a0poster document class, at least, that was my experience. When I set background in blue
\usepackage{color}
\definecolor{page_backgroundcolor}{rgb}{0.0234375, 0.339844, 0.710938}
\pagecolor{page_backgroundcolor}
the background within the shadowbox was blue. It seems not possible to adjust background color.
\shadowbox{\parbox[c][5cm]{0.98\columnwidth}{%
\begin{center}
Some box content here
\par\end{center}%
}}
\par
Then I started looking for alternative box packages.
Staying with a0poster examples, I found tcolorbox. This has more parameters, seems to be fine in a0poster documents. I tested on a beamer poster and the results are also GOOD. Downright surprising, actually. It usually seems to me that beamer contradicts special-purpose packages.
The beamer package has its own block environment, but I find that harder to adjust to taste than tcolorbox in a beamer document.
I want you to tell me if I'm just having beginners luck. Or should I focus on some other box package. When I needed to do color within tables last year, I found there were quite a few problems in adjusting colors in cells and lines and if I'm going to run into that with tcolorbox, you could warn me now.
I also have experimented with tikzposter which offers its own very elaborate system for creating boxes, but I'm not pursuing that right now because it appears to be very specialized (not portable) work. Correct?
If tcolorbox is the right place to focus, let me know. If not, what should I study.
There seems to be no clear question, that makes a clear answer hard, but a few comments to the things you mention in the text:
tcolorbox is usually safe to use with beamer
\usepackage{color} is not necessary if you use the beamer document class, it already loads xcolor
Instead of setting the page colour with
\pagecolor{page_backgroundcolor}
I suggest to use the beamer way of doing this and use
\setbeamercolor{background canvas}{bg=page_backgroundcolor}
I would stay well away from tikzposter, it tempts its users to nest tikzpictures, which should better be avoided. Also it nests tikzpictures itself if innerblocks are used.
I have a lot of data to plot in a single plot window and it looks really ugly and not understandable. Moreover legends are coming on to the curves which make curves unreadable. I cannot put curve alone one by one into my latex report which makes it again difficult to maneuver between the plots.
My question is- can't it be possible to put all the curves in single plot generated from gnu plot which can be easily maneuver back and forth in a single plot window the latex report?
I know a bit about tikz pictures where no of frameworks can be easily accessible in single plot.
can't it be used for a whole curves one by one assuming as different frame work. and at last all the plots in the the plot window.
It would be very helpful if is possible so.
I have data with N rows and M columns in it. I need plots of N rows vs. each column separately to be shown in each frame in Latex generated report and in the last frame all the curves should be present. I need a proper procedure to follow to animate the curves.
Yes, this kind of thing can be done with the animate package in latex. I have successfully used it in the past for presentations that I put together with beamer. You could switch between different gnuplot graphs that are loaded into the animateinline environment, but you can also use pgfplots within tikz to modify the plot directly on your latex document without need for an external plot.
Using animate requires investing a bit of time at the beginning but the results can be very nice. Also, Okular (and I'm guessing other PDF viewers as well) seem to have trouble visualizing the animations but Adobe reader (acroread on linux) loads them without problems.
As an example, you can check a 5-minute presentation I put together last year: in slides 4 and 5 you can use the buttons to run the animation. The one in slide 4 includes plotting a gaussian with pgfplots changing the curve parameters between frames. You need to open it with the Adobe reader for it to play correctly.
If my designer gives me a 960x640px image of what the screen should look like, as well as all of the individual elements as images or text, is there a way to lay out the images and text on the iPhone/iPad screen without doing it manually through code? The way I'm doing it now is a series of trial and error, trying to guess the position of each element.
By the way, the types of layouts I'm trying to do are simple static layouts for stuff like Menus and High Scores lists, etc.
You should try one of the editing tools: LevelHelper, CocoShop and CocosBuilder. The problem will be the output format, make sure that not only the editing part works to your specification but that you can actually use just the snippet of code you need to plug it into your code.
Do you have an image-editing software like Photoshop or GIMP? How about opening the 960x640px image with any such software, then hovering your mouse over the center of each element for its coordinates, and then finally pumping these values into your code?
In my opinion, this is at least better and way faster than trial and error:)
If you want to measure position of graphic elements. You can try a commercial called xscope. The trail version can be downloaded form their official website. It is the best tool I ever seen to measure distance, color(like, it can copy color measured directly to [UIColor ...] format), etc. If you want something freeware, I would like to recommend markman, which is a Chinese software, it's built on adobe air. All elements/button are graphic, so you don't need to read chinese to use it..
You can try to use some open source editor and write your exporter. For example I am using blender as a level editor for the game I am working on. It has a nice python API that can be used to export all the information you need.
I am looking for a library that would help scrape the information from the image below.
I need the current value so it would have to recognise the values on the left and then estimate the value of the bottom line.
Any ideas if there is a library out there that could do something like this? Language isn't really important but I guess Python would be preferable.
Thanks
I don't know of any "out of the box" solution for this and I doubt one exists. If all you have is the image, then you'll need to do some image processing. A simple binarization method (like Otsu binarization) would make it easier to process:
The binarization makes it easier because now the pixels are either "on" or "off."
The locations for the lines can be found by searching for some number of pixels that are all on horizontally (5 on in a row while iterating on the x axis?).
Then a possible solution would be to pass the image to an OCR engine to get the numbers (tesseractOCR is an open source OCR engine hosted at Google (C++): tesseractOCR). You'd still have to find out where the numbers are in the image by iterating through it.
Then, you'd have to find where the lines are relative to the keys on the left and do a little math and you can get your answer.
OpenCV is a beefy computer vision library that has things like the binarization. It is also a C++ library.
Hope that helps.
I am using subfloats to import 2 .png files in a figure to basically generate subfigures. There's no space between the figures when I compile it. How do I put some white space in between them? And is it possible to convert them to black and white using LaTeX?
Try \vskip 1em between the figures. If this doesn't work, post your nonworking figure code so we can see what's going on.
To put white space in between them, you can throw a \quad—or anything that makes whitespace—in between the subfloats within the figure. Converting to grayscale is not in the graphicx package as far as I can see; all the literature on it says to use an external program. My first instinct is to explore TikZ (a LaTeX package) just because it is so powerful, but I have no idea if it can do anything with external graphics. This Page deals with compile time options to specify a grayscale or color version. For example, if you have all the color images in one folder, you batch convert them to grayscale and put them in a separate folder with identical filenames. Then, at compile time, specify from which folder to get the images. See the comments for the graphicspath implementation.