Show graphs inside a module in Mathematica

I want to show graphs inside a module (possibly recursively):

m = Module[{i, j}, i = 3; Plot[Sin[t], {t, 0, 1}]; j = 4] 

Even

 m = Module[{i, j}, i = 3; Show[Plot[Sin[t], {t, 0, 1}]]; j = 4] 

does not work. Why is it and how to build it right?

+6
source share
1 answer

The only reason graphs are usually displayed in Mathematica is because the Plot function returns a graphical object representing the graph, and Mathematica displays the return value of what you run on the laptop. However, when you execute a statement with a semicolon, you do not allow it to return a value.

What you can do if you need to display something from the middle of the module is Print[Plot[...]]; . The Print function displays the value of its argument directly.

+11
source

Source: https://habr.com/ru/post/904796/


All Articles