Easy Latex Titles and Labels for ggplot

Summary

Ever wanted to add \(\LaTeX\) to your R plots? Well now you can, with tikz, and it will allow you to use \(\LaTeX\) code within your plot titles, labels, and annotations. We’re going to look at how to use \(\LaTeX\) (text formating, formulas, fractions, greek letters, etc) with your ggplot data visualizations. We will be using the tikzDevice package for R (and to use your plots in \(\LaTeX\), you will use the package tikz).

Libraries

Open up an R script! You will need to install these two libraries if you don’t already have them:

library(ggplot2)
library(tikzDevice)

Data

Unrelated to learning how to use tikzDevice, we need some data to play with. Here we will generate some data to plot:

x     <- rnorm(n = 100, mean = 10, sd = 10)
alpha <- 2.0
beta  <- 1.5
gamm  <- 10
err   <- rnorm(n=100, mean=0, sd = 0.25)
f_x   <- alpha / (1 + exp(-1 * beta * (x - gamm))) + err

dat   <- data.frame(x=x, y=f_x)

Before we start with the \(\LaTeX\), here is what the data looks like when we plot it:

g1 <- ggplot(data=dat, aes(x=x, y=y)) + 
        geom_smooth(method="loess") + 
        geom_point() + 
        theme_classic()
g1

Adding \(\LaTeX\)

Now for the fun part! You use \(\LaTeX\) with the same notation you would in a .tex file, but you need to escape backslashes (for example instead of \textbf{Hi}, you need to use \\textbf{Hi}).

# here we open a tex file for output, and set the plots dimensions
tikzDevice::tikz(file = "./example_plot.tex", width = 5, height = 3)

# here we add a LaTeX title to the plot
g2 <- g1 + ggtitle("$f(x, \\alpha, \\beta, \\gamma)$")
g2
# closing the graphics device saves the file we opened with tikzDevice::tikz
dev.off()
## png 
##   2

Okay, let’s have a look at what the g2 object looks like in R:

print(g2)

You can see the \(\LaTeX\) code in the title, but not the generated output you would hope to see. However, that output is saved in “./example_plot.tex”, which you can now include in any .tex document:

To include this plot in a .tex document, you can use:

input{example_plot.tex}

But remember to include the tikz package!

\usepackage{tikz}

or (not recommended due to lack of readability) you can copy and paste the contents of the file example_plot.tex into your \(\LaTeX\) document. If you want to see the contents of the file example_plot.tex, scroll down to the Appendix (I’ve put it at the end of this post since the output is a few hundred lines long).

Title, Labels, Annotations

Here I will show you in one plot how easy it is to add \(\LaTeX\) to each of the text components of the plot.

# here we open a tex file for output, and set the plots dimensions
tikzDevice::tikz(file = "./example_plot_2.tex", width = 5, height = 3)

# here we add a some LaTeX to the plot
g3 <- g1 + 
  ggtitle("$f(x, \\alpha, \\beta, \\gamma)$") +
  xlab(label = "$x \\sim rnorm(\\mu=10, \\sigma=10)$") +
  ylab(label = "$f(x)=\\frac{\\alpha}{1 + exp( - \\beta (x-\\gamma) )}+\\varepsilon$") +
  annotate(geom  = "text", 
           x     = c(0,0,0), 
           y     = c(2,1.8,1.6), 
           label = c("$\\alpha=2$", "$\\beta=1.5$", "$\\gamma=10$"),
           hjust = 0)
g3
# closing the graphics device saves the file we opened with tikzDevice::tikz
dev.off()
## png 
##   2

References

I would like to point you towards the tutorial by Ilyass Tabiai, which is where I first learnt about tikzDevice: Latex + R + tikzDevice

As well as the very nice comparison of options made by Rob J Hyndman: Mathematical annotations on R plots

Appendix

example_plot.tex (click to expand)

\begin{tikzpicture}[x=1pt,y=1pt]
\definecolor{fillColor}{RGB}{255,255,255}
\path[use as bounding box,fill=fillColor,fill opacity=0.00] (0,0) rectangle (433.62,289.08);
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{255,255,255}
\definecolor{fillColor}{RGB}{255,255,255}

\path[draw=drawColor,line width= 0.6pt,line join=round,line cap=round,fill=fillColor] (  0.00,  0.00) rectangle (433.62,289.08);
\end{scope}
\begin{scope}
\path[clip] ( 29.87, 29.59) rectangle (428.12,265.39);
\definecolor{fillColor}{RGB}{255,255,255}

\path[fill=fillColor] ( 29.87, 29.59) rectangle (428.12,265.39);
\definecolor{fillColor}{RGB}{153,153,153}

\path[fill=fillColor,fill opacity=0.40] ( 47.97,134.91) --
    ( 52.55,129.88) --
    ( 57.14,125.09) --
    ( 61.72,120.54) --
    ( 66.30,116.23) --
    ( 70.89,112.17) --
    ( 75.47,108.37) --
    ( 80.05,104.81) --
    ( 84.63,101.52) --
    ( 89.22, 98.48) --
    ( 93.80, 95.70) --
    ( 98.38, 93.18) --
    (102.97, 90.93) --
    (107.55, 88.92) --
    (112.13, 87.17) --
    (116.71, 85.66) --
    (121.30, 84.37) --
    (125.88, 83.30) --
    (130.46, 82.44) --
    (135.05, 81.77) --
    (139.63, 81.27) --
    (144.21, 80.95) --
    (148.79, 80.80) --
    (153.38, 80.81) --
    (157.96, 80.99) --
    (162.54, 81.35) --
    (167.13, 81.55) --
    (171.71, 81.36) --
    (176.29, 81.13) --
    (180.87, 81.19) --
    (185.46, 81.84) --
    (190.04, 83.31) --
    (194.62, 84.61) --
    (199.21, 85.53) --
    (203.79, 87.29) --
    (208.37, 90.85) --
    (212.95, 96.67) --
    (217.54,104.51) --
    (222.12,114.01) --
    (226.70,124.67) --
    (231.29,135.81) --
    (235.87,146.58) --
    (240.45,158.27) --
    (245.03,172.27) --
    (249.62,186.89) --
    (254.20,200.14) --
    (258.78,209.94) --
    (263.37,218.58) --
    (267.95,226.97) --
    (272.53,234.13) --
    (277.11,239.38) --
    (281.70,243.68) --
    (286.28,247.20) --
    (290.86,250.00) --
    (295.45,252.09) --
    (300.03,253.46) --
    (304.61,254.12) --
    (309.19,254.26) --
    (313.78,254.21) --
    (318.36,253.97) --
    (322.94,253.53) --
    (327.53,252.90) --
    (332.11,252.07) --
    (336.69,251.06) --
    (341.27,249.88) --
    (345.86,248.55) --
    (350.44,247.08) --
    (355.02,245.48) --
    (359.61,243.76) --
    (364.19,241.93) --
    (368.77,239.98) --
    (373.35,237.92) --
    (377.94,235.73) --
    (382.52,233.43) --
    (387.10,230.99) --
    (391.69,228.41) --
    (396.27,225.69) --
    (400.85,222.82) --
    (405.43,219.80) --
    (410.02,216.61) --
    (410.02,145.67) --
    (405.43,154.33) --
    (400.85,162.53) --
    (396.27,170.27) --
    (391.69,177.56) --
    (387.10,184.39) --
    (382.52,190.78) --
    (377.94,196.71) --
    (373.35,202.20) --
    (368.77,207.24) --
    (364.19,211.84) --
    (359.61,216.00) --
    (355.02,219.74) --
    (350.44,223.07) --
    (345.86,226.00) --
    (341.27,228.56) --
    (336.69,230.76) --
    (332.11,232.62) --
    (327.53,234.18) --
    (322.94,235.44) --
    (318.36,236.43) --
    (313.78,237.14) --
    (309.19,237.59) --
    (304.61,237.76) --
    (300.03,237.43) --
    (295.45,236.46) --
    (290.86,234.77) --
    (286.28,232.27) --
    (281.70,228.92) --
    (277.11,224.70) --
    (272.53,219.53) --
    (267.95,212.53) --
    (263.37,204.05) --
    (258.78,195.05) --
    (254.20,185.16) --
    (249.62,171.91) --
    (245.03,156.89) --
    (240.45,142.15) --
    (235.87,130.01) --
    (231.29,119.51) --
    (226.70,108.95) --
    (222.12, 98.66) --
    (217.54, 89.14) --
    (212.95, 81.05) --
    (208.37, 75.20) --
    (203.79, 72.06) --
    (199.21, 70.59) --
    (194.62, 69.58) --
    (190.04, 68.12) --
    (185.46, 66.68) --
    (180.87, 66.01) --
    (176.29, 65.77) --
    (171.71, 65.69) --
    (167.13, 65.50) --
    (162.54, 64.98) --
    (157.96, 64.35) --
    (153.38, 63.85) --
    (148.79, 63.49) --
    (144.21, 63.27) --
    (139.63, 63.17) --
    (135.05, 63.19) --
    (130.46, 63.32) --
    (125.88, 63.54) --
    (121.30, 63.82) --
    (116.71, 64.17) --
    (112.13, 64.55) --
    (107.55, 64.96) --
    (102.97, 65.37) --
    ( 98.38, 65.78) --
    ( 93.80, 66.18) --
    ( 89.22, 66.57) --
    ( 84.63, 66.93) --
    ( 80.05, 67.27) --
    ( 75.47, 67.58) --
    ( 70.89, 67.87) --
    ( 66.30, 68.12) --
    ( 61.72, 68.34) --
    ( 57.14, 68.53) --
    ( 52.55, 68.68) --
    ( 47.97, 68.80) --
    cycle;
\definecolor{drawColor}{RGB}{51,102,255}

\path[draw=drawColor,line width= 1.1pt,line join=round] ( 47.97,101.85) --
    ( 52.55, 99.28) --
    ( 57.14, 96.81) --
    ( 61.72, 94.44) --
    ( 66.30, 92.18) --
    ( 70.89, 90.02) --
    ( 75.47, 87.97) --
    ( 80.05, 86.04) --
    ( 84.63, 84.22) --
    ( 89.22, 82.52) --
    ( 93.80, 80.94) --
    ( 98.38, 79.48) --
    (102.97, 78.15) --
    (107.55, 76.94) --
    (112.13, 75.86) --
    (116.71, 74.91) --
    (121.30, 74.10) --
    (125.88, 73.42) --
    (130.46, 72.88) --
    (135.05, 72.48) --
    (139.63, 72.22) --
    (144.21, 72.11) --
    (148.79, 72.15) --
    (153.38, 72.33) --
    (157.96, 72.67) --
    (162.54, 73.16) --
    (167.13, 73.53) --
    (171.71, 73.53) --
    (176.29, 73.45) --
    (180.87, 73.60) --
    (185.46, 74.26) --
    (190.04, 75.72) --
    (194.62, 77.10) --
    (199.21, 78.06) --
    (203.79, 79.68) --
    (208.37, 83.03) --
    (212.95, 88.86) --
    (217.54, 96.83) --
    (222.12,106.34) --
    (226.70,116.81) --
    (231.29,127.66) --
    (235.87,138.30) --
    (240.45,150.21) --
    (245.03,164.58) --
    (249.62,179.40) --
    (254.20,192.65) --
    (258.78,202.50) --
    (263.37,211.31) --
    (267.95,219.75) --
    (272.53,226.83) --
    (277.11,232.04) --
    (281.70,236.30) --
    (286.28,239.74) --
    (290.86,242.38) --
    (295.45,244.28) --
    (300.03,245.45) --
    (304.61,245.94) --
    (309.19,245.92) --
    (313.78,245.67) --
    (318.36,245.20) --
    (322.94,244.49) --
    (327.53,243.54) --
    (332.11,242.34) --
    (336.69,240.91) --
    (341.27,239.22) --
    (345.86,237.28) --
    (350.44,235.08) --
    (355.02,232.61) --
    (359.61,229.88) --
    (364.19,226.88) --
    (368.77,223.61) --
    (373.35,220.06) --
    (377.94,216.22) --
    (382.52,212.10) --
    (387.10,207.69) --
    (391.69,202.99) --
    (396.27,197.98) --
    (400.85,192.68) --
    (405.43,187.06) --
    (410.02,181.14);
\definecolor{drawColor}{RGB}{0,0,0}
\definecolor{fillColor}{RGB}{0,0,0}

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (277.94,249.10) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (233.16, 97.40) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (112.90, 64.76) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (251.40,215.98) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (180.07, 79.37) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (327.22,223.84) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (206.34, 92.38) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (218.13, 81.84) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (176.54,108.00) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (243.67,169.25) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (195.53, 77.27) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (267.25,231.25) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (144.29, 52.41) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (288.56,244.33) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (317.32,229.23) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (257.67,216.96) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (177.67, 73.95) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (305.09,215.04) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (193.05, 89.41) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] ( 47.97, 88.74) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (237.03,112.31) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (219.51, 62.29) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (308.05,242.51) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (295.11,254.67) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (328.88,208.82) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (261.90,197.71) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (365.95,223.89) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (240.08,146.91) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (263.92,242.20) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (248.28,219.28) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (192.57, 99.90) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (239.13,132.94) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (329.50,226.71) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (236.17,115.45) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (184.70, 92.26) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (200.67, 88.59) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (211.92, 75.45) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (134.62, 90.37) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (201.33, 48.06) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (208.42, 90.40) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (284.67,228.27) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (410.02,206.33) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (105.54, 52.02) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (261.34,205.09) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (207.46,113.25) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (190.03, 71.10) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (356.51,217.45) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (219.38, 90.46) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] ( 85.78,116.69) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (268.67,238.48) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (167.49, 76.90) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (162.95, 96.94) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (255.90,232.91) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (336.01,222.63) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (208.14, 93.85) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (228.57, 86.30) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (305.34,235.46) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (143.52, 87.24) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (274.04,243.74) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (335.81,212.71) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (248.99,209.84) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (233.59,131.95) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (210.27, 97.93) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (232.35,108.37) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (238.08,133.50) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (271.17,215.44) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (197.39, 56.94) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (135.00, 94.33) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (215.33, 75.67) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (273.99,224.62) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (195.45, 64.81) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (265.33,247.98) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (201.30,115.19) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (129.66, 74.37) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (269.04,215.73) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (182.86, 75.09) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (154.96, 80.89) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (286.79,233.71) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (289.54,225.12) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (265.30,237.20) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (252.56,199.58) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (285.82,247.51) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (160.52, 63.83) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (276.44,238.84) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (339.32,239.42) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (211.93, 40.31) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (176.76,115.35) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (192.51, 83.55) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (309.08,222.87) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (277.29,211.95) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (171.44, 89.58) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (168.84, 95.53) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (252.76,193.64) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (273.30,224.34) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] ( 95.66, 90.72) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (175.31, 59.67) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (181.52, 99.71) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (295.43,226.67) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (237.68,128.12) circle (  1.96);

\path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round,fill=fillColor] (257.73,237.81) circle (  1.96);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{0,0,0}

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 29.87, 29.59) --
    ( 29.87,265.39);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{gray}{0.30}

\node[text=drawColor,anchor=base east,inner sep=0pt, outer sep=0pt, scale=  0.88] at ( 24.92, 82.91) {0};

\node[text=drawColor,anchor=base east,inner sep=0pt, outer sep=0pt, scale=  0.88] at ( 24.92,153.84) {1};

\node[text=drawColor,anchor=base east,inner sep=0pt, outer sep=0pt, scale=  0.88] at ( 24.92,224.77) {2};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{gray}{0.20}

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 27.12, 85.94) --
    ( 29.87, 85.94);

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 27.12,156.87) --
    ( 29.87,156.87);

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 27.12,227.80) --
    ( 29.87,227.80);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{0,0,0}

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 29.87, 29.59) --
    (428.12, 29.59);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{gray}{0.20}

\path[draw=drawColor,line width= 0.6pt,line join=round] ( 46.02, 26.84) --
    ( 46.02, 29.59);

\path[draw=drawColor,line width= 0.6pt,line join=round] (176.34, 26.84) --
    (176.34, 29.59);

\path[draw=drawColor,line width= 0.6pt,line join=round] (306.65, 26.84) --
    (306.65, 29.59);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{gray}{0.30}

\node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  0.88] at ( 46.02, 18.58) {-20};

\node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  0.88] at (176.34, 18.58) {0};

\node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  0.88] at (306.65, 18.58) {20};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{0,0,0}

\node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.10] at (228.99,  5.50) {x};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{0,0,0}

\node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.10] at ( 13.08,147.49) {y};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (433.62,289.08);
\definecolor{drawColor}{RGB}{0,0,0}

\node[text=drawColor,anchor=base west,inner sep=0pt, outer sep=0pt, scale=  1.32] at ( 29.87,274.49) {$f(x, \alpha, \beta, \gamma)$};
\end{scope}
\end{tikzpicture}

Related