Open iembry-USGS opened 8 years ago
Hi Irucka,
With a slight correction, your code works for me without error.
First change is to use only single quotes '...'
inside your script text, which itself is quoted using "..."
; that removes the error.
Second change, is to add print -dpng
at the end of your script. Without this, you won't see the figure.
I'm suspecting this works, because it writes a file somewhere temporarily, that RcppOctave automatically picks up and shows.
I'm using
R version 3.3.3 (2017-03-06) -- "Another Canoe"
GNU Octave, version 4.0.2
on Ubuntu 16.04
Here is a new version of your example:
library(RcppOctave)
o_source(text = "
clf;
hold on;
fplot('2*sin(theta)+2', [0 2*pi]); % page 443 Brockman
fplot('[cos(x), sin(x)]', [0 2*pi])
fplot(@cos, [0, 2*pi])
grid on
set(findobj(gca, 'Type', 'Line'), 'LineWidth', 2);
set(gca,'fontsize',14);
title('Waves');
xlabel time
ylabel something
print -dpng
")
Output:
Cheers, Steven
PS: The RcppOctave team has done a great job with this interface!
PPS: An afterthought: Since o_source(text="close all")
can be used to close the figure window, I'm not sure whether it shows up because of the temporary .png
file, or whether print
does something else that brings the initially hidden Octave figure window to the screen.
@iembry-USGS, which version of RcppOctave are you using?
I added better support for plots when fixing issue #10 (dfd3e0f and 29e5e23).
This is available from the develop
branch. Please let me know if this solves your problem.
I've tried version 18.03 in the development branch. After fixing a minor compilation issue in pull request #17, the package installs and plots show up without needing the print
command, I used in the last line of my example above.
I'm not the original poster, but my problem with this is solved. Thanks!
@renozao, I'm sorry for my delayed response: RcppOctave 0.18.1. Thank you for your continued development of this package.
@git-steb, I too am sorry for my delayed response. Thank you for your suggestions. I have tried your code unsuccessfully.
I am using:
R version 3.4.0 (2017-04-21) -- "You Stupid Darkness" RcppOctave 0.18.1 - Unsuccessfully tried to install development version (see new issue) GNU Octave 3.8.1 Trisquel 7.0 (Ubuntu 14.04)
The R code:
library(RcppOctave)
o_source(text = "
+ clf;
+ hold on;
+ fplot('2*sin(theta)+2', [0 2*pi]); % page 443 Brockman
+ fplot('[cos(x), sin(x)]', [0 2*pi])
+ fplot(@cos, [0, 2*pi])
+ grid on
+ set(findobj(gca, 'Type', 'Line'), 'LineWidth', 2);
+ set(gca,'fontsize',14);
+ title('Waves');
+ print -dpng
+ ")
# Error below:
Error in .CallOctave("source", file) :
RcppOctave - error in Octave function `source`:
invalid value = northeast
set: invalid value for radio property "location" (value = northeast)
called from:
/usr/share/octave/3.8.1/m/plot/appearance/legend.m at line 995, column 11
/usr/share/octave/3.8.1/m/plot/draw/fplot.m at line 176, column 7
/tmp/RtmpAkNtud/mfile_150849a05703 at line 4, column 1
Thank you.
Irucka
Hi, I am attempting to follow some examples of
fplot
in GNU Octave with RcppOctave. Although there are errors in GNU Octave, all 3 of the plots are drawn, but none of them are drawn in R.in R 3.2.4 (there are no plots)
In addition, in R, this is the error message that appears:
Error: unexpected string constant in: " fplot(@cos, [0, 2*pi]) ""
in GNU Octave 3.8.1 (although I have the errors, all 3 of the attempted plots are drawn)
Thank you.
Irucka