Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multible y-axix (more than two) in wxdraw2d() #1836

Open
ReneSci opened this issue Nov 6, 2023 · 2 comments
Open

Multible y-axix (more than two) in wxdraw2d() #1836

ReneSci opened this issue Nov 6, 2023 · 2 comments

Comments

@ReneSci
Copy link

ReneSci commented Nov 6, 2023

Would it be possible to implement some gnuplot code that makes plots like this possible?
image

https://stackoverflow.com/questions/27390317/how-to-plot-multiple-y-axes

@gunterkoenigsmann
Copy link
Member

Two axis are possible - and I use them frequently:

wxdraw2d(
    explicit(sin(x),x,0,2*π),
    xlabel="x [rad]",
    xlabel_secondary="x [°]",
    xrange_secondary=[0,360],
    xaxis_secondary=true,
    xtics_secondary=true,grid=[5,5]
);

But multiplots aren't currently possible for maxima's png and pngcairo output that wxMaxima uses - and what draw is missing is the possibility to add raw gnuplot commands: There is gnuplot_preamble, but you cannot insert a

set ytics offset  -8, 0

into exactly the current place in the gnuplot file maxima creates. Both features would be possible feature requests for the maxima project, though: At least the latter I would use from time to time.

@daute
Copy link
Member

daute commented Jan 29, 2024

Well - if the function can be expressed using Gnuplot commands and you just want to include it in a wxMaxima worksheet, the following trick may help:

(Code taken from the Stackoverflow page you referenced).

Here I am plotting the function y=0 (with x= 0-10), so it is not shown - and afterwards I insert the gnuplot commands using gnuplot_postamble. Quotes need to be escaped, of course.

wxplot2d(0,[x,0,10],[gnuplot_postamble,"
set multiplot
clear
set xrange[0:10]

# We need place to the left, so make the left margin 30% of screen
set lmargin screen 0.3

##### first plot

set ytics 0.4
set yrange[-1.2:1.2]

set ylabel \"Voltage\" textcolor rgb \"red\"

plot sin(x)


##### Second plot

set ytics 1
set yrange[-3:3]

set ytics offset  -8, 0
set ylabel \"Current\" offset -8, 0 textcolor rgb \"green\"

plot 3*cos(x) linecolor 2

##### Third plot

set ytics 0.5
set yrange[-1.5:1.5]


set ytics offset -16, 0
set ylabel \"Power\" offset -16, 0  textcolor rgb \"blue\"
plot 3*sin(x)*cos(x) linecolor 3

unset multiplot"])$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants