# Latex charts similar to scientific graph

I found this awesome library for python which enables drawing nice plots https://github.com/garrettj403/SciencePlots is it possible to create similar styled graphs with latex ? I have used pgfplots but they don't look nowhere near with this style

Edit: First of all, I am newbie to latex and pgfplots.

So far I have created a tikzpicture and received error for domain p for the function

    \begin{tikzpicture}
\begin{axis}[
ylabel = {Current ($\mu$A)},
xlabel = {Voltage (mV)},
scaled ticks=false,
]
\addplot[domain=0:1.4,domain p=10:20]{x ^ (2 * p + 1) / (1 + x ^ (2 * p))};
\end{axis}
\end{tikzpicture}


It gives an output like the following

What I am trying make is the ticks on both x and y axis, method to define colors each time I add a new plot, and making the y axis start from 0 to 1.2

Also do I need to specify samples large to make the graph look like linear rather than squares showing the values ?

• The simple answer is yes. And besides the cycle list the default style isn't that far away from the image you are showing in your question. If you want to help us to replicate the exact style it would be nice if you could show us your current best result. Otherwise your question tends to sound like a "Just do it for me" question. Aug 30, 2020 at 11:18
• Hello thank you for the feedback, I have updated the post sorry Aug 30, 2020 at 12:12

Welcome to TeX.SE. A pgfplots graph. See the code for further explanations. My thanks to @StefanPinnow for the improvements he suggested.

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer,units}
\pgfplotsset{compat=1.17,
colormap/Dark2,             %activate the colormap for the sequence of plots
legend pos=north west       % legend in NW corner of canvas
}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmin=0.75,xmax=1.25,ymin=0,ymax=1.2, % set x- and y-axis limits
domain=0.75:1.25,                    % Calculate function values in the interval
samples=101,                         % Number of points to calculate for functions
no markers,                          % no markers on plots
smooth,                              % draw smooth functions
tick label style={/pgf/number format/fixed, %tick label styling (e.g. number of decimal points)
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1},
cycle list name=Dark2,               % colormap for functions
x SI prefix=milli,x unit= V,         % SI units on x axis
y SI prefix=micro,y unit= A,         % SI units on y axis
xlabel={Voltage},                    % x axis label
ylabel={Current}                     % y axis label
]
\addlegendimage{empty legend}          % Make a space at the top of the legend table for a heading
\foreach \p in {10,15,20,30,50,100} {        % Plot the function at p=0.1, 0.12 etc
\addplot{x ^ (2 * \p + 1) / (1 + x ^ (2 * \p))};
\addlegendentryexpanded{\p}          % Add the function to the legend
}

\end{axis}
\end{tikzpicture}

\end{document}

• Good attempt! Maybe some comments: Most important, please add (non-automatic) domain=0.75:1.25 to the axis options, because that is the only range you show. But without that statement domain defaults to the range -5 to 5 and thus calculates a lot more. That is also why you have to use a that high samples number. Given the domain you can reduce to samples=101 to show up the same "precision" as with your current version. Aug 31, 2020 at 5:12
• And second the grid and first tick label style keys are superfluous in this code, because you given the keys their default values. Aug 31, 2020 at 5:15
• @StefanPinnow Thanks for the feedback. That's an excellent tip on the domain. I am going to leave the tick label style because my observation is that manipulating the tick labels is not intuitive for most beginners, By leaving this code embedded in the axis options it at least gives people a starting point for what needs to be changed should they need to do that. I'll add this explanation to the post. For me, it helps with having too many code chunks to remember, especially when those details change from graph to graph.
– Ross
Aug 31, 2020 at 5:38
• You are welcome. My comment was just for /pgf/number format/assume math mode=true. I personally never had to change this. You? Then keep domain and samples keys together, because they belong together. A better explanation for these keys is then: domain = "Calculate function values in the interval ..."; samples = "Number of points to calculate for functions" Aug 31, 2020 at 5:47
• @StefanPinnow My standard practice is to make plots with font=\sffamily added as an option to the tikzpicture environment. If I don't include tick label style = {/pgf/number format/assume math mode=true}, the tick labels are roman so this is just a carry over from my standard style. I'll delete it.
– Ross
Aug 31, 2020 at 6:11