How to Print scalable figures with Octave and a Brother MFC-J625DW printer - plot

My Printer is a Brother MFC-J625DW ink jet.
I wrote a simple circle and square plot, which I would like to give me scalable circles and squares.
I can get a figure1.I don't know how to print out the figure.
If I set axis(equal) then I am able to use prt screen and One Drive.
I can print out the image and with a ruler determine a scale factor.
There must be a way of specifying the printer and taking figure1 which doesn't relate to a print statement and print it directly from Octave.
Help.
Thank you, Yehuda
attached the code that doesn't print
%circleincart
r1=10.1/2 %inner circle
r2= 11.87/2 % Outer circle
s1=15.895 %square;
r4= 8.34/2;
t=[0:0.1:2*180];
thrd=pi/180*t;
x1=r1*cos(thrd);
y1=r1*sin(thrd);
x2=r2*cos(thrd);
y2=r2*sin(thrd);
x10=r1/7*cos(thrd);
y10=r1/7*sin(thrd);
x20=r2/7*cos(thrd);
y20=r2/7*sin(thrd);
x3=[-7.9475 ,-7.9475 ,7.9475, 7.9475, -7.9475];
y3=[-7.9475 ,7.9475 , 7.9475 -7.9475 -7.9475];
x30=x3/7; %7 is the scaling factor
y30=y3/7;
scfctrsmallest=r4/r2/7;
x40= scfctrsmallest*x2;
y40= scfctrsmallest*y2;
x5=[-10,10];
y5=[0,0];
x6=[0,0];
y6=[-10,10];
plot(x1,y1,x2,y2,x3,y3,x20,y20,x10,y10,x30,y30,x40,y40,x5,y5,x6,y6);
%plot(x5,y5,x6,y6);
axis("square")
%print -dpsc
%print (1,-PMFCJ625DW)
print figure1
print -dpsc
%print -dsvg "path/to/fig1"
% -djpg figure1
%print -dpng figure1
%print -PMFC-J625DW
%print (-PMFC-J625DW);
Succeeded with print screen and One Drive.
Couldn't get Octave to recognize printer (maybe a path problem).
Need way of Octave to print the figure1.

Related

gnuplot - plot both from a data file and a gnuplot function in a single image

I have the following snippet:
set grid
set xlabel "Entropy"
set ylabel "Amortized work"
set xrange [-0.05:1.05]
set style line 1 linecolor rgb '#516db0' linetype 2 linewidth 5
f(x) = -1.3973 * x ** 2 + 1.3947 * x + 0.5796
F = '$-1.3973 x^2 + 1.3947 x + 0.5796$'
set terminal cairolatex pdf input size 700,700 color colortext
set key opaque box lc "black" linewidth 3
plot 'RatioVerboseData.dat', f(x)
set output
The data file RatioVerboseData.dat looks like this:
0.93070 0.290710
0.94060 0.281450
0.95050 0.254771
0.96040 0.241656
When I run the script with the gnuplot, it outputs:
plot 'RatioVerboseData.dat', f(x)
^
cairolatex terminal cannot write to standard output
"EntropyVerboseData.plt", line 15: util.c: No error
I use gnuplot 4.6.7 and MiKTeX-pdfTeX 4.10 (MiKTeX 22.7)
You need to specify an output file. Otherwise gnuplot tries to write back to the input terminal (stdout). That makes sense for some terminal types, e.g. the "dumb" terminal, and is not revelant for terminal type with their own display window, e.b. "qt", "wxt". But it cannot work for terminal types that need to create multiple output streams and then combine them to produce the final document, which covers most (all?) of the LaTeX terminal types.
Add a line:
set output "RatioVerboseData.tex"
Why are you using a 7.5 year old gnuplot version? Current version is 5.4.
I can reproduce your observation (on Win10 with gnuplot 4.6.7) that gnuplot gets stuck.
I couldn't find a hint in help cairolatex, but I guess if you don't add units to the size it will be interpreted as inches. But this does not yet explain why gnuplot freezes when you want to create a 700in x 700in large graph.
Anyway, if you add units, I guess at least in and cm are accepted and if you add the output file as #Ethan already suggested then it should work.
...
set terminal cairolatex pdf input size 7cm,7cm color colortext
set output "RatioVerboseData.tex"
...

How to prevent Jupyter Notebook from cutting output?

When I print, for some reason Jupyter cuts some text out of the middle of output ( perhaps to make it more readable), but I need to see it.
What are the possible solutions?
Is there any option I can change in Jupyter to prevent if from cutting?
P.S. Sorry can't embed images yet. Use the link, thx.
enter image description here
my_pipeline = make_pipeline(ce.OneHotEncoder(use_cat_names=True),
SimpleImputer(),
XGBRegressor(n_estimators=1000,
learning_rate=0.01,
clf__early_stopping_rounds=10,
clf__eval_set=[(test_X, test_y)],
random_state=45,
verbose=True))
# fitting and predicting
print(my_pipeline.fit(train_X, train_y))
predictions = my_pipeline.predict(test_X)
print("Mean Absolute Error : " + str(mean_absolute_error(predictions,
test_y)))
OUTPUT:
Pipeline(memory=None,
steps=[('onehotencoder', OneHotEncoder(cols=['Neighborhood'], drop_invariant=False,
handle_unknown='impute', impute_missing=True, return_df=True,
use_cat_names=True, verbose=0)), ('simpleimputer', SimpleImputer(copy=True, fill_value=None, missing_values=nan, strategy='mean',
ver... reg_lambda=1, scale_pos_weight=1, seed=None, silent=True,
subsample=1, verbose=True))])
As you see on the OUTPUT by the "ver..." - it is cut. Thx.

Making a TIME SERIES graph THAT SCROLLS WITH THE DATA in R

I need to do exactly the graph that has been made on this page (the second one)
http://www.animatedgraphs.co.uk/line.html
Here is my actual code :
timemax<-151737 # number of frames (and observations - so no interpolation needed)
setwd("C:/Users/victo/Downloads/ffmpeg/ffmpeg/bin/")
vis<-100 # how many time points are on the screen at one time
gdata<-data.frame('Temps'= data$time,'RH_Xacc'= data$RH_Xacc)
gname<-paste("g",1:timemax,".tif", sep="") # holds the names of the picture files
right<-(((1:timemax)<=vis)*100)+(((1:timemax)>vis)*1:timemax) # rightmost time on screen
left<- right-vis+2 # leftmost time on screen
leftlab<-200*ceiling((left-1)/200) # leftmost x label
rightlab<-200*floor(right/200) # rightmost x label
# draw graphs
for (i in 1:timemax) {
tiff(gname[i],width=480)
plot(gdata$Temps[right[i]:left[i]],gdata$RH_Xacc[right[i]:left[i]],col="red",type="l",ylim=c(-100,200),xlim=c(right[i],left[i]),xaxt="n",ylab="",xlab="time")
axis(1,at=seq(from=rightlab[i],to=leftlab[i],by=12))
lines(gdata$Temps[right[i]:i],gdata$RH_Xacc[right[i]:i])
dev.off(dev.cur())
}
# call FFMPEG and make the video
shell("C:/Users/victo/Downloads/ffmpeg/ffmpeg/bin/ffmpeg.exe -codecs -i g%d.tif -b:v 2048k gdata.mpg",mustWork=FALSE)
My code seems to work until the shell function. I don't get an error. The code just never stops running. I am not able to get the video with all the data. Can someone tell me where is the problem ? How can I get the video or if there is an other to get the same result ? I've tried the library gganimate but i didn't succeed either... I am doing this in Rstudio and using sweave.
Thanks a lot
Actually, the first thing you should do is probably run the command :
C:/Users/victo/Downloads/ffmpeg/ffmpeg/bin/ffmpeg.exe -codecs -i g%d.tif -b:v 2048k gdata.mpg directly and not with a calling shell from RStudio. You would have a more verbose output.
Original post
Do you have any CPU performance profiling tool ? I suspect that the shell command might take a lot of time to run on your computer since in your example : timemax<-151737 whereas the example has a shorter timemax timemax<-1000
Try your program with a low value of timemax (=1000) and time the execution of the code. I guess you could extrapolate the total time needed to execute multiplying by 150 (I am not an expert of ffmpeg, it might actually be longer)

Overlapping lines in Gnuplot when exporting

I'm trying to plot a discrete brownian path in gnuplot, which involves a lot of overlaping lines. This is how it's displayed in the qt terminal (I have generated the image with a screenshot):
Notice how the overlapping lines get colored in a stronger color, which is beautiful.
If I export it in png, with
set term pngcairo size 1366,768 enhanced
I obtain this:
All the lines have the same intensity. Setting transparent doesn't help, either.
The same happens with this MWE:
set term pngcairo size 1366,768 background '#000000' enhanced
set output "image.png"
unset key
set border 0
unset xtics
unset ytics
set samples 1e6
set xrange [0:0.1]
p sin(1/x) w l lw 0.3
set output
I'm running gnuplot -d each time so my local config does not get loaded. How should I export the plot to obtain the same effect as in the GUI?
Here are some results of my investigation :
I couldn't achieve beautiful results with pngcairo either. Opacity isn't added when 2 curves overlap each other.
Exporting to SVG and converting to PNG looked a bit better, either with inkscape -z -e image.png -w 1600 -h 1200 image.svg or convert -density 3000 -resize 1600x1200 image.svg image.png. This step could be included in gnuplot as a system command.
It is possible to export the qt render to png directly from the qt window. First menu icon on the left → Export to image
This process could in theory be automated directly from Gnuplot, without user interaction. A patch has been submitted : https://sourceforge.net/p/gnuplot/patches/665/. As far as I can tell, it hasn't been yet integrated into Gnuplot 5.0.x
Here is a related discussion on Gnuplot-dev.
If you feel adventurous, you could try to recompile Gnuplot with the applied patch. The submitter might be able to help you.
Very offtopic in this question, but as a workaround I have made a Julia script that replicates the image feeling that I am looking for. I will post it here in case anybody finds it useful.
using Images
function paint(Ny, Nx, iters=1e6; stepsize = 50)
randstep() = rand([-1;1])
x = Nx÷2
y = Ny÷2
M = zeros(Nx,Ny)
for i in 1:iters
rx = randstep()
ry = randstep()
for i in 1:stepsize
x = mod1(x+rx, Nx)
y = mod1(y+ry, Ny)
M[x,y] += 1
end
end
clamped = M/maximum(M)
img = [Colors.RGB(0,mm,0) for mm in clamped]
end
img = convert(Image,paint(1366,768,1e4,stepsize=10))
save("coolbrownianwalk.png", img)
This produces images like this:

Logarithmic x and y axis for image plot

I need to do this in a different way, since pcolor produces diagonal lines in the output file
h=pcolor(rand(16)); %The actual data comes from hist3
set(h,'EdgeColor','none');
colormap(gray(256));
set(gca,'yscale','log');
set(gca,'xscale','log');
print('test.png','-dpng','-r4800'); %Gives diagonal lines in text.png
Is there a simple workaround the bug. I use the FLTK backend.
Update
Switching to gnuplot removes the diagonal lines, but adds vertical and horizontal lines, but changes increases the plot margins too much.
Here is a "solution" to the bug. The idea is to disable anti-aliasing for graphics.
gswrapper.sh
#!/bin/bash
ARGS=()
ARGS+=("-dGraphicsAlphaBits=1")
for var in "$#"; do
[ "$var" != '-dGraphicsAlphaBits=4' ] && ARGS+=("$var")
done
gs "${ARGS[#]}"
Octave script:
h=pcolor(rand(16)); %The actual data comes from hist3
set(h,'EdgeColor','none');
colormap(gray(256));
set(gca,'yscale','log');
set(gca,'xscale','log');
print('test.png','-dpng','-r600','-G./gswrapper.sh');

Resources