help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Axes object in Octave 2.9.12 and other plotting questions


From: Mark B.
Subject: Re: Axes object in Octave 2.9.12 and other plotting questions
Date: Thu, 14 Jun 2007 15:18:20 -0700 (PDT)

Hello,

I was able to sort out most of my problems but I am still unable to
customize the ticks and tick labels for axis X. I have made my script
runnable under Matlab 7 and Octave 2.9.12 for Windows (compiled with MSVC by
David Bateman). Under the former, the script runs without problems and the
plot shows the custom ticks, but in the latter it seems impossible to
customize the ticks. Furthermore, the x tick labels appear messed up. Can
please somebody point out how to make this work? I am including my function
and a test script so that you can try everything by yourselves.

I need your help on this guys, please! If one cannot get help in the
official Octave mailing list, then where?

Thanks in advance!


%%%%%%%%%%%
% test script         %
%%%%%%%%%%%

numpoints=216;
x=ones(1, numpoints);
x=[0 cumsum(x)];
y1=randn(1, numpoints+1);
y2=rand(1, numpoints+1);
createafigure(x, y1, y2)


%%%%%%%%%%%%%%%%%%%%%%%%
% My function to plot with tick labels in axis x
% save it as createafigure.m
%%%%%%%%%%%%%%%%%%%%%%%%

function createafigure(X1, YMatrix1, YMatrix2)
% Create figure
figure1 = figure;

% 'language_of' obtained from:
https://svn.apl.washington.edu/websvn/filedetails.php?repname=brad_svn&path=%2Fsar_iw%2Ftrunk%2Flanguage_of.m
program = language_of();

% Create axes
if (strcmp(program, 'matlab'))
  axes1 = axes('Parent',figure1,...
     
'XTickLabel',{'02/13','02/14','02/15','02/16','02/17','02/18','02/19','02/20','02/21','02/22'},...
      'XTick',[0 24 48 72 96 120 144 168 192 216],...
      'Position',[0.13 0.11 0.7943 0.815]);
  box('on');
  hold all
elseif (strcmp(program, 'octave'))
  axes1 = axes();
  axes(axes1);
  box('on');
end

plot1 = plot(X1,YMatrix1);

set(plot1,'Color',[0 0 1]);

if (strcmp(program, 'octave'))
  % Changing axes1 to gca() does not make any difference
  set (axes1, 'XTickLabelMode', 'manual');

  % apparently this is completely ignored by gnuplot 4.2
  set (axes1, 'XTick', [0,24,48,72,96,120,144,168,192,216]);

  % this makes gnuplot to show the labels messed up
  set (axes1, 'XTickLabel',
{'02/13';'02/14';'02/15';'02/16';'02/17';'02/18';'02/19';'02/20';'02/21';'02/22'});

  % This make gnuplot to show only the first label for all the ticks. 
  % set (axes1, 'XTickLabel',
{'02/13';'02/14';'02/15';'02/16';'02/17';'02/18';'02/19';'02/20';'02/21';'02/22'}');
end

hold on;

plot2 = plot(X1,YMatrix2);

set(plot2,'LineStyle',':');
set(plot2,'Color',[1 0 0]);

% Create xlabel
xlabel('Time (in days)');

% Create ylabel
ylabel('Counts');

legend('show');
legend('Normal','Not normal',2);
axis tight

-- 
View this message in context: 
http://www.nabble.com/Axes-object-in-Octave-2.9.12-and-other-plotting-questions-tf3909893.html#a11129858
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]