rlkamalapurkar / bodeplot

LaTeX package to plot Bode diagrams
LaTeX Project Public License v1.3c
6 stars 1 forks source link

Interferance with pgf plots #11

Closed mxxmxn closed 5 months ago

mxxmxn commented 5 months ago

When I create a pgf plot and bodeplot is included, the output looks incorrect.

The following code normally results in a good output.

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
%\usepackage[pgf,Hz]{bodeplot}
\begin{document}
    \begin{tikzpicture}
        \def\uf{sin(deg(2*pi*.125))} 
            \begin{axis}
            [axis x line = center,
            grid=major,
            xtick distance={1},
            xlabel style={right},
            xlabel={\(t\) in ms},
            xmin=0,
            xmax=2.25,
            axis y line = center,
            ytick={0,\uf,-1},
            yticklabels={\(0\),\(u_f\),\(-\hat{u}_0\)},
            ylabel style={above},
            ylabel={\(u(t)\)},
            ymin={-1.25},
            ymax={\uf+.25}]
                \addplot[blue, samples=15, domain=0:.125, variable=\x]{sin(deg(2*pi*x))};
                \addplot[blue, samples=2, domain=.125:.375, variable=\x]{sin(deg(2*pi*.125))};
                \addplot[blue, samples=120, domain=.375:1.125, variable=\x]{sin(deg(2*pi*x)};
                \addplot[blue, samples=2, domain=1.125:1.375, variable=\x]{sin(deg(2*pi*1.125)};
                \addplot[blue, samples=75, domain=1.375:2, variable=\x]{sin(deg(2*pi*x)};
                %
                \addplot[cyan, samples=240, domain=0:2, variable=\x]{.5*sin(deg(2*pi*x))};
            \end{axis}
    \end{tikzpicture}
\end{document}

image

But with bodeplot the output looks like this: image

rlkamalapurkar commented 5 months ago

Thanks for the report, I set trig format plots=rad in bodeplot to make it compatible with both gnuplot and pgfplots, so your trigonometric functions are being interpreted in radians, not degrees. I will fix this and upload a new version soon.

In the meantime, adding trig format plots=deg to the axis options of all non-bodeplot plots should work as a band-aid.

mxxmxn commented 5 months ago

Thank you, with the option it works fine.

rlkamalapurkar commented 5 months ago

Great! When I fix it and you get the updated bodeplot package, you will have to remove that option to get the plots right, sorry about that!

mxxmxn commented 5 months ago

Ok, sounds great. Thanks for the great work on this package.

rlkamalapurkar commented 5 months ago

This is fixed in version 1.2