Graphics, Figures & TablesResolution of fonts in TikZ plots

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Resolution of fonts in TikZ plots

Post by LKB »

Hi All,
I just started working with TikZ and while results are very pleasing the actual plots looks a bit pixalated. Is there any easy way of changing output plots resolution ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10350
Joined: Mon Mar 10, 2008 9:44 pm

Re: Resolution of TikZ plots

Post by Stefan Kottwitz »

You could raise the number of samples used for plotting and use smooth paths for connecting the plot points. Perhaps show your example plot code.

Stefan
LaTeX.org admin
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Resolution of fonts in TikZ plots

Post by LKB »

Stefan,
The problem seems to be mostly visible with text, and as I mentioned the whole plot looks pixelated. I would pferer to to have 300dpi data instead of what I expect is 72dpi.
I was hoping there is some command allowing you to increase the dpi of the output. Only other way I see, which is troublesome, is to make a big plot and scale it down but text problematic as it does not scale down.

My code:

Code: Select all

\newcommand*{\TXTin}[1]{node[black, sloped, midway, inner sep=.1cm,fill=white]{#1}} \newcommand*{\TXTout}[1]{node[black, midway, below, sloped]{#1}}
\definecolor{LightGrey}{HTML}{BFBFBF}

\begin{tikzpicture}
%earth
\fill[LightGrey] (6,6) -- (3,0) \TXTin{R} -- (0,6) \TXTin{R} to [out=25,in=165] (6,6);
\draw [dashed,ultra thick] (0,6) to [out=25,in=165] (6,6);
\draw [dashed] (0,6) -- (3,0) \TXTin{R} -- (6,6) \TXTin{R}; \filldraw [black] (3,0) circle (2pt);

%observer
\draw (0,6) -- (0,8) \TXTout{$h_{rov}$} -- (6,6) \TXTin{LOS};
\filldraw [gray] (0,8) circle (3pt);
\node [above right] at (0,8) {Observer};

\end{tikzpicture} 
edit: remove extra code lines, add extra explanation
Last edited by LKB on Mon Aug 13, 2012 10:49 am, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10350
Joined: Mon Mar 10, 2008 9:44 pm

Resolution of fonts in TikZ plots

Post by Stefan Kottwitz »

LKB wrote:The problem seems to be mostly visible with text
So I guess it's a font issue. Perhaps you are using a bitmap font, not a type 1 vector font.
LKB wrote:

Code: Select all

\begin{tikzpicture} [resolution: 300 300]
resolution is not a valid option.

When I remove this, the picture is ok and can be scaled without getting pixelated.
picture.png
picture.png (9.96 KiB) Viewed 5084 times
picture-zoomed.png
picture-zoomed.png (15.56 KiB) Viewed 5084 times
Stefan
LaTeX.org admin
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: Resolution of TikZ plots

Post by LKB »

Thank you,
This might be a font issue indeed. On my output it does look like bitmap has been rescaled. Could you advice how can I change the font? I use Lyx as a front-end here but I suspect that font problem got more to do with pdflatex.

I just corrected the code - you are much faster then me ...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10350
Joined: Mon Mar 10, 2008 9:44 pm

Resolution of fonts in TikZ plots

Post by Stefan Kottwitz »

The default (Computer Modern) font can look pixelated with T1 font encoding. Instead of the default font I would use Latin Modern, which is very similar, provides high quality and also T1 support.

Simply add

Code: Select all

\usepackage{lmodern}
to your document preamble.

Stefan
LaTeX.org admin
LKB
Posts: 19
Joined: Wed Jul 11, 2012 5:19 pm

Re: Resolution of TikZ plots

Post by LKB »

Magic. Thank you.
Post Reply