
Regarding the graph, I would use pst-plot myself but many people use TikZ these days.
\psplot
command. (See for example page 8--9 in the manual.) If you are not familiar with RPN notation, you can use the algebraic
option for the plot command.
\documentclass{article} \usepackage{pgfplots} \pgfplotsset{ compat = 1.7 , yticklabel style = {/pgf/number format/.cd,fixed,fixed zerofill,precision=4} , samples = 100 , scaled ticks = false } \usepackage{chemmacros} \usepackage{siunitx} \sisetup{per-mode=symbol} \begin{document} \begin{tikzpicture} % parameter: \def\kB{1.3806488e-23}% boltzmann constant \def\temperature{298}% room temperature \def\Beta{1/(\kB*\temperature)} \def\amu{1.660538921e-27}% atomar mass unit in kg \def\HMass{2*\amu}% Hydrogen \def\HeMass{4*\amu}% Helium \def\OMass{32*\amu}% Oxygen % plot: \begin{axis}[ domain = 0:5000 , xlabel = $v$ in \si{\metre\per\second} , ylabel = $P(v)$ , title = Maxwell-Boltzmann distribution of different gases at room temperature ] \addplot[color=red] {sqrt(2/pi)*(\HMass*\Beta)^(3/2)*x^2*exp(-.5*\HMass*\Beta*x^2)} ; \addplot[color=yellow] {sqrt(2/pi)*(\HeMass*\Beta)^(3/2)*x^2*exp(-.5*\HeMass*\Beta*x^2)} ; \addplot[color=blue] {sqrt(2/pi)*(\OMass*\Beta)^(3/2)*x^2*exp(-.5*\OMass*\Beta*x^2)} ; \legend{\ch{H2},\ch{He},\ch{O2}} \end{axis} \end{tikzpicture} \begin{tikzpicture} % parameter: \def\kB{1.3806488e-23}% boltzmann constant \def\hundredK{100}% 100 K \def\rt{300}% ~ room temperature \def\thousandK{1000}% 100 K \def\Beta#1{1/(\kB*#1)} \def\amu{1.660538921e-27}% atomar mass unit in kg \def\HMass{2*\amu}% Hydrogen % plot: \begin{axis}[ domain = 0:8000 , xlabel = $v$ in \si{\metre\per\second} , ylabel = $P(v)$ , title = Maxwell-Boltzmann distribution for Hydrogen at different temperatures ] \addplot[color=red] {sqrt(2/pi)*(\HMass*\Beta{\hundredK})^(3/2)*x^2*exp(-.5*\HMass*\Beta{\hundredK}*x^2)} ; \addplot[color=yellow] {sqrt(2/pi)*(\HMass*\Beta{\rt})^(3/2)*x^2*exp(-.5*\HMass*\Beta{\rt}*x^2)} ; \addplot[color=blue] {sqrt(2/pi)*(\HMass*\Beta{\thousandK})^(3/2)*x^2*exp(-.5*\HMass*\Beta{\thousandK}*x^2)} ; \legend{\SI{100}{\kelvin},\SI{300}{\kelvin},\SI{1000}{\kelvin}} \end{axis} \end{tikzpicture} \end{document}
ghostanime2001 wrote:I am not familiar at all with tex sadly
ghostanime2001 wrote:what is /def ? I am not familiar at all with tex sadlyAlso the x-axis is in velocity (m/s) but I wanted kinetic energy so shouldn't the equation used to compute the graph be different as well ?
\def
is a TeX's low level command for LaTeX's \newcommand*
. It can be replaced by the latter in every case except \def#1{<foo bar>}
which needs to be replaced with \newcommand*\foo[1]{<foo bar>}
.
\def\foo{bar} = \newcommand*\foo{bar} \long\def\ff{bar} = \newcommand\foo{bar} \def\foo#1{bar: #1} = \newcommand\foo[1]{bar: #1} \def\foo#1#2{bar: #1 and #2} = \newcommand\foo[2]{bar: #1 and #2}
\newcommand
doesn't overwrite existing commands for instance but \def
does) but that's it basically.
\documentclass{article} \usepackage{etex} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot[red] {sin(deg(x))}; \end{axis} \end{tikzpicture} \end{document}
ghostanime2001 wrote:[...] it draws corners at curves of functions. Is there a way to draw functions which has smooth points indefinitely ...
\documentclass{article} \usepackage{etex} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot[red,samples=100] {sin(deg(x))}; \end{axis} \end{tikzpicture} \end{document}
I've never heard of it before but my favorite search engine tells me Reverse Polish Notation.ghostanime2001 wrote:By the way, what is RPN notation ?
svend_tveskaeg wrote:If you are not familiar with RPN notation, you can use the algebraic option for the plot command.
Return to “Graphics, Figures & Tables”
Users browsing this forum: No registered users and 9 guests