0

I'm unable to plot a bode_gain inside the GUI of wxmaxima, I know that for example, "wxplot" plots inside the GUI but putting the prefix on bode_gain function doesn't work for me, so

Can someone help me by telling me how to plot a bode_gain function inside wxmaxima GUI instead of using a new graphic window?

Progman
  • 16,827
  • 6
  • 33
  • 48
vram
  • 85
  • 8
  • Welcome to Stack Overflow. Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then [edit] your question to include your source code as a working [mcve], which can be compiled and tested by others. Please see: [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/q/284236). – Progman Nov 24 '21 at 20:56
  • For the benefit of people reading this: the problem is that `bode_gain` is calling some plotting function on its own, and it's not the one that makes embedded plots. Let me look at what it would take to fix it up so it makes embedded plots. – Robert Dodier Nov 25 '21 at 04:53

1 Answers1

2

On looking at the code (share/contrib/bode.mac), I see there's no provision to call different plotting functions, it's always the built-in plot2d. For wxMaxima it's nice to be able to use wxplot2d since that makes embedded plots.

Here's a way to replace the call to plot2d in the definition of bode_gain and bode_phase.

load ("bode.mac");
''(subst (plot2d = wxplot2d, fundef (bode_gain)));
''(subst (plot2d = wxplot2d, fundef (bode_phase)));

Note carefully the first two characters are two single quotes, not a double quote. The quote-quote '' has the effect of evaluating the modified function definition, constructed by subst, from the existing function definition returned by fundef.

A different way is to find bode.mac in your installation, and edit the file to say wxplot2d instead of plot2d wherever the latter appears.

I will update bode.mac so that the plotting function is more easily changed, and that new version will appear in future releases (5.46 is the next one) of Maxima.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • Thanks a lot @Robert Dodier, your answer works flawlessly. I don't know why but I was searching in the installation directory for the specific function instead of looking for the bode.mac file; anyway I don't know enough knowledge of maxima programming to change the function so probably I would have taken my a lot of time to change the behavior so, Thanks for the master class. – vram Nov 26 '21 at 13:50
  • I'm glad to hear it works for you. Maxima is an idiosyncratic programming language, but one of the things it is good at is programming after the fact. It's an oversight that bode.mac doesn't allow for calling a different plotting function, but luckily Maxima makes it relatively easy to work around. For the record, I've pushed a commit to establish a global variable `bode_plot2d` which is `plot2d` by default, and can be changed to `wxplot2d`. That change will be part of the next (5.46) Maxima release. – Robert Dodier Nov 26 '21 at 20:45