Aquaterm: titles and axis labels getting cut off - image

I'm using aquaterm 1.0.1 through octave and gnuplot - on my mac - to generate printable plots. When aquaterm generates my plots, it has a habit of cutting off or cropping all of the titles and axis labels.
Is there another imaging program that works with octave that won't have this problem? Or are there other fixes I haven't thought of?

I prefer the plot results from aquaterm more than x11. I wrote an m-file script, which is really a kludge, to fix this problem so aquaterm is useable. It seems like the title and xlabel text strings are written one line too high and too low in the figure window. Note -this script doesn't change the ylabel. If the magnitude of the printed y-coordinate values are too large, it tends to move the ylabel off the left side of the page. Anyway here is my kludge, just run it after all figures are complete.
function fixAxes
%---------------------------------------
%// Kludge to fix scaling of all figures
%// until GNU or I can find real fix.
%// Octave3.2.3 computes the scaling wrong
%// for this mac, such that the title
%// and xlabel are not displayed.
%---------------------------------------
s = get(0,'showhiddenhandles');
set(0,'showhiddenhandles','on');
newpos = [0.13 0.135 0.775 0.75]; %// default is [0.13 0.11 0.775 0.815]
figs = get(0,'children');
if (~isempty(figs))
for k=1:length(figs)
cax = get(figs(k),'currentaxes');
pos = get(cax,'position');
if ~(pos(1) == newpos(1) && ...
pos(2) == newpos(2) && ...
pos(3) == newpos(3) && ...
pos(4) == newpos(4))
set(cax,'position',newpos);
set(0,'currentfigure',figs(k));
drawnow();
endif
endfor
endif
set(0,'showhiddenhandles',s);
%---------------------------------------
endfunction
%---------------------------------------

While I don't know why aquaterm cuts of parts of your plot, you can try using X11 terminal. In Octave, you can say setenv GNUTERM 'x11' to do so.

Related

graphics shows me the figures with a black background, but when they are saved in the folder I defined, they are saved with a white background

Why at the time of graphing shows me the figures with a black background, but when they are saved in the folder I defined, they are saved with a white background?
i am using:
figure(1)
pcolor(X./1000,Y./1000,real(Var))
title(['RR [mm/h] - ', datestr(time(ii)), ' EL = ' ,num2str(elv)])
shading flat
caxis([0 30])
axis([-60 60 -60 60])
colorbar
colormap(jet)
set(gca,'Color','k')
path='A:\Documentos\IGP\Radar PX_1000\Plots\260218\';
gfile=[path,'R',datestr(time(ii),'ddmmyy_HHMMSS')]
print(gfile,'-dpng','-r300')
print does some funny things to figures when it saves them (I believe using a white background is one of them). If you're looking to replicate what the image looks like in final output, I'd recommend export_fig. From the documentation at the link:
Note that the background color and figure dimensions are reproduced (the latter approximately, and ignoring cropping & magnification) in the output file.

How to place an arrow at the end of axis label in Gnuplot?

I would like to place an arrow at the end of the axis labels (NOT on the plot). Currently I am using dashes (---) followed by greater than symbol (>) instead. Would prefer using arrows.
Thanks
Although the answer is a bit late, the easiest is probably to use the Unicode character U+2192 →
This works even with gnuplot 4.6.0 (2012). If your arrow is too small you can enlarge it with enhanced text mode which should work at least with gnuplot>=5.0.0 (2015).
Code:
reset
set xlabel "x-label --->\nx-label →\nx-label {/:Normal=20 →}"
set ylabel "y-label --->\ny-label →\ny-label {/:Normal=20 →}"
plot x
Result:

How are progress bars programmed in Conky and how can I apply this in my own custom one?

I'm trying to customize my progress bars in Conky (battery_bar, fs_bar...) in order to have a layout other than the default one, which looks like:
Following this answer I managed to create a filesystem usage bar, and with some code modifying, a battery status one, looking like this.
This bar is generated following the following script, a variation of the one suggested for in the previous answer:
#!/bin/bash
cat /sys/class/power_supply/BAT0/capacity | awk 'NR==1{
n = ($1+0)/2; yellow = 20; red = 40;
if(n>=red) {
r = "${color ff0000}";
for(;n>=red;n--)
r = r "\\#"
}
if(n>=yellow){
y = "${color ffff00}";
for(;n>=yellow;n--)
y = y "\\#"
}
g = "${color 00ff00}";
for(;n>0;n--)
g = g "\\#";
print g y r
}'
My problem is that the bar's length is constant, and it will constantly resize the Conky window until it's able to show the 100% of its capacity, full size. This obviously forces my Conky window size to be at least the length of those custom bars, deforming the screen.
As far as I have experimented, I can see that Conky's default bars are 'responsive' to the windows size they are given, and never cause problems in this aspect; as they resize themselves without a problem. I would like to know how are they programmed in order to apply the same algorithm to my code the cleanest way.
One thing you can do fairly easily is add some programming in lua to change the font size just before drawing the bar. The size would be calculated from the window width divided by 50. If using proportional fonts you might need some small scale factor to account for the fact that a font of a given size might have a # character of a different width.
Create a file to hold the lua script, say ~/mylua.lua with the following
-- called with (50) return "${font DejaVu Sans Mono:size=13.6}"
function conky_mysetfont(numchars)
if conky_window.width<=0 then return "" end
fontname = "DejaVu Sans Mono"
scale = 1.2
fontsize = conky_window.text_width/tonumber(numchars)*scale
-- print("result=",fontsize) -- debug
return "${font "..fontname..":size="..fontsize.."}"
end
The -- starts a comment. If you remove the one in front of print, you
should see something like result= 13.6 on stdout if you run conky
from the terminal. The function takes a parameter, the length of your bar,
ie 50 characters. It returns a conky command string like ${font
somefont:size=13.6}. .. is a concatenation operator. The above choses a fixed-width font DejaVu Sans Mono and an approximate scale of 1.2.
In your ~/.conkyrc, add in the conky.config = {...} part (for 1.10) a line
lua_load = '~/mylua.lua',
to load in your code. In the conky.text = [[...]] part, replace the line
where call your script, eg
${execpi 30 ~/mydf /}
with
${lua_parse conky_mysetfont 50}
${execpi 30 ~/mydf /}
$font
i.e. call your lua function, passing the number of characters, your
original script, then reset the original default font and size.
In conky 1.9 when you resize the window with the mouse, this code
will change the font size to match, but in 1.10 the size changes only when
the window changes size due to some internal trigger. It seems this is a
regression.
Note that many people don't have problems with resizing because they
display conky on their fixed-size desktop background.
Also, once you start using lua, an alternative to using text for bars
is to get lua to draw any sort of graphics such as coloured lines and
boxes. You can read about this in the wiki, and see amazing
examples
of what is possible.
possibly not 100% an answer to your question but you may give it a try
I am using conky 1.10.6 on a raspberry pi with KDE Desktop.
I am using one line to display most of the file systems (vfat partition excluded with option -x).
${execpi 60 df -h --output=source,target -x vfat| grep '^/dev/' | cut --characters=6- | awk '{ print $1," ", $2,"${alignr}${fs_size " $2 "}","${alignr}${color blue}${fs_bar 11,100 " $2"}\n\n\n,${alignr}${voffset -39}${color white}${fs_used_perc " $2 "}%" }'}
Result:
cheers

Plot time series and image in R so that x axis labels line up perfectly

I am trying to plot a time series (a seismograph) with a corresponding spectrogram in R.
Since I would like to compare the time series with the spectrogram, the X axis labels on the time series need to line up with the X axis labels on the spectrogram. However, I'm having a lot of trouble with this. The best I've been able to do so far is use
par(mar=c(0,10,0,8))
and try to manually force the spectrogram labels to line up with the time series labels by tweaking the spectrogram margin. Of course this is only approximate and they still do not line up perfectly. Is there a way to make the axes generated by the code below match up with each other?
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l",xlab="Time",
ylab="Amplitude", main="Time Series", xlim=c(1,10))
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram", xlim=c(1,10))
Thanks in advance!
This seems to work:
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l", xaxs="i")
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram")
Just drop the xlim= arguments and use xaxs="i" in the plot() function to match the default for image().
You can either add xaxs='i' to the call to plot (this removes the extra padding so it lines up with the image plot), or you could use par('usr') after the 1st plot to see what the x limits are and use those values in the xlim call in image.
It turns out that this is way easier than it looked initially. The secret is to make a "dummy plot" and then add the image to the plot. So here's how the new, working code looks:
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01),
type="l",xlab="Time",ylab="Amplitude", main="Time Series")
plot(c(0,10), c(0,10), type="n") #Dummy plot with axis limits for our spectrogram
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram",add=TRUE)
Similar, but conversely, to Greg Snow's answer, you could add xaxs='r' to the call to image as follows:
par(mar=c(0,10,0,8))
par(mfcol=c(2,1))
plot(seq_len(1000)*0.01, sin(2*pi*seq_len(1000)*0.01), type="l",xlab="Time",
ylab="Amplitude", main="Time Series", xlim=c(1,10))
image(seq_len(1000)*0.01,seq_len(100)*0.1,array(runif(1000000),dim=c(1000,100)),
xlab="Time", ylab="Frequency", main="Spectrogram", xlim=c(1,10), xaxs="r")
Don't forget to save your par() setting first.
(maybe I should have put that above)

Embedding matlab plot in pdf for printing: Sizes

I'm currently creating my figures in matlab to embed themvia latex into a pdf for later printing. I save the figures and save them via the script export_fig! Now I wonder which is the best way to go:
Which size of the matlab figure window to chose
Which -m option to take for the script? It will change the resolution and the size of the image...
I'm wondering about those points in regards to the following two points:
When chosing the figure-size bigger, there are more tickmarks shown and the single point markers are better visible
When using a small figure and using a big -m option, I still have only some tickmarks
When I generate a image which is quite huge (e.g. resolution 300 and still 2000*2000px) and than embed it into the document: Does this than look ugly? Will this be embedded in a nice scaling mode or is it the same ugliness as if you upload a 1000*1000px image onto a homepage and embed it via the widht and height tags in html -> the browser displays it quite ugly because the browser doesn't do a real resize. So it looks unsharp and ugly.
Thanks in advance!
The MATLAB plots are internally described as vector graphics, and PDF files are also described using vector graphics. Rendering the plot to a raster format is a bad idea, because you end up having to choose resolution and end up with bigger files.
Just save the plot to EPS format, which can be directly embedded into a PDF file using latex. I usually save my MATLAB plots for publication using:
saveas(gcf, 'plot.eps', 'epsc');
and embed them directly into my latex file using:
\includegraphics[width=0.7\linewidth]{plot.eps}
Then, you only need to choose the proportion of the line the image is to take (in this case, 70%).
Edit: IrfanView and others (XnView) don't display EPS very well. You can open them in Adobe Illustrator to get a better preview of what it looks like. I always insert my plots this way and they always look exactly the same in the PDF as in MATLAB.
One bonus you also get with EPS is that you can actually specify a font size so that the text is readable even when you resize the image in the document.
As for the number of ticks, you can look at the axes properties in the MATLAB documentation. In particular, the XTick and YTick properties are very useful manually controlling how many ticks appear no matter what the window resolution is.
Edit (again): If you render the image to a raster format (such as PNG), it is preferable to choose the exact same resolution as the one used in the document. Rendering a large image (by using a big window size) and making it small in the PDF will yield bad results mainly because the size of the text will scale directly with the size of the image. Rendering a small image will obviously make for a very bad effect because of stretching.
That is why you should use a vector image format. However, the default MATLAB settings for figures produce some of the same problems as raster images: text size is not specified as a font size and the number of ticks varies with the window size.
To produce optimal plots in the final render, follow the given steps:
Set the figure's font size to a decent setting (e.g. 11pt)
Render the plot
Decide on number of ticks to get a good effect and set the ticks manually
Render the image to color EPS
In MATLAB code, this should look somewhat like the following:
function [] = nice_figure ( render )
%
% invisible figure, good for batch renders.
f = figure('Visible', 'Off');
% make plots look nice in output PDF.
set(f, ...
'DefaultAxesFontSize', 11, ...
'DefaultAxesLineWidth', 0.7, ...
'DefaultLineLineWidth', 0.8, ...
'DefaultPatchLineWidth', 0.7);
% actual plot to render.
a = axes('Parent', f);
% show whatever it is we need to show.
render(a);
% save file.
saveas(f, 'plot.eps', 'epsc');
% collect garbarge.
close(f);
end
Then, you can draw some fancy plot using:
function [] = some_line_plot ( a )
%
% render data.
x = -3 : 0.001 : +3;
y = expm1(x) - x - x.^2;
plot(a, x, y, 'g:');
title('f(x)=e^x-1-x-x^2');
xlabel('x');
ylabel('f(x)');
% force use of 'n' ticks.
n = 5;
xlimit = get(a, 'XLim');
ylimit = get(a, 'YLim');
xticks = linspace(xlimit(1), xlimit(2), n);
yticks = linspace(ylimit(1), ylimit(2), n);
set(a, 'XTick', xticks);
set(a, 'YTick', yticks);
end
And render the final output using:
nice_figure(#some_line_plot);
With such code, you don't need to worry about the window size at all. Notice that I haven't even showed the window for you to play with its size. Using this code, I always get beautiful output and small EPS and PDF file sizes (much smaller than when using PNG).
The only thing this solution does not address is adding more ticks when the plot is made larger in the latex code, but that can't be done anyways.

Resources