Vini
Vini

Reputation: 18

Why are subscripts not interpreted with the standard octave-4.0.0 graphics toolkit?

I am relatively new to Octave, and I am having trouble saving a figure, consisting of a set of subplots generated with "for" loops.

To illustrate this issue, I have generated the sample code shown at the bottom of this post. After defining the independent (x) and dependent (y = 2*x) variables, a for loop goes from i = 1:4, and each time a random number vector (err) is generated with the randn function. On each step of the for loop, a subplot is generated, which contains: (a) original data (y) illustrated as a solid line; (b) random data (y + i*err) illustrated as coloured markers.

The subplots with their corresponding lines and markers are correctly generated by the GNU Octave interface, and the y-axis label format ylabel('f(x) = y, f(x) = y_{rand}') is also displayed as desired with string "rand" shown as a subindex.

However, when I try to save the figure with either the "print" or "saveas" functions for pdf or eps formats, only the random data (coloured markers) is kept and the yaxis label is explicitly displayed as: "f(x) = y. f(x) = y_{rand}", ignoring the formatting.

For reference, I am running Octave 4.0.0 on Ubuntu 14.04 LTS, and the Linux OS is run from a virtual machine using Windows 8.1.

Thanks for your attention.

Vinicio

clf
clear all
clc

% Define the indepedent (x) and dependent (y) variables
x = 0:1:20;
y = 2*x;

% Allocate random error vector
err = zeros(1, length(x));
color = jet(4);

for i = 1:4

  % Generate random error vector with mean = zero, var = 1
  err = randn(1, length(x));

  subplot(2, 2, i)

    % Plot original data (y)
    plot(x, y, '-k', 'markersize', 9)
    hold on

    % Plot random data (y + err)
    plot(x, y + i.*err, 'ok', 'markerfacecolor', color(i, 1:end))
    hold on    

  % Edit plot
  set(gca, 'fontsize', 16)  
  ylabel('f(x) = y, f(x) = y_{rand}')
  xlabel('x')
  ylim([-10 50])
  hold all

end

% Set directory and save figure
cd ~/Documents/Octave;
saveas(gcf, "fig1.eps")

Upvotes: 0

Views: 787

Answers (1)

ederag
ederag

Reputation: 2509

This wrong behavior can be reproduced in 4.0.0 with this shorter example:

axes
ylabel("f(x) = y, f(x) = y_{rand}")

It has been fixed in the current development version, so no need to file a bug report.

Meanwhile, as a workaround, graphics_toolkit("gnuplot") can be used.

Please remember to create a new figure, or to close all, before testing. Indeed, the previous graphics_toolkit is still used for the existing figures.

Upvotes: 1

Related Questions