Hi Jack,
Thanks for your response. Sorry for not being clearer.
My
python src blocks often have both graphical output as well as the
results of some numerical calculation displayed using print statements.
#+begin_src python :results file
import numpy as np
import matplotlib.pyplot as plt
def f(x): return np.polyval(a, x)
a = [1, -4, 4.5, -1.5]
x = np.roots(a)
print(f'Roots of the polynomial are {x}')
x_ = np.linspace(np.min(x), np.max(x), 100)
plt.plot(x_, f(x_))
plt.plot(x, f(x), marker='o')
plt.savefig('img/ex1.png')
return 'img/ex1.png'
#+end_src
Executing this results in
#+RESULTS:
[[file:img/ex1.png]]
When exported I would like the line: return 'img/ex1.png' not to be included in the listing of the src block.
Also,
the output of the print statement is not displayed in this case. It
seems that the display of the results of the print statement:
print(f'Roots of the polynomial are {x}') , would require execution of a
duplicate src block without the return statement in the last line, and
with ':results output' replacing ':results file' which gives:
#+RESULTS:
: Roots of the polynomial are [2.3660254 1. 0.6339746]
I would have liked to avoid the duplication if possible.
Thanks,
RC