# HG changeset patch # User Juan Pablo Carbajal # Date 1418747147 -3600 # Node ID cdb6bc186c42d393c35f61c703098026252062fb # Parent 06b23f224f52388f4f54bd3f9ef6ff0a7adae4a3 Fix ploting 1D images with gnuplot (bug #43836). * __go_draw_axes__.m: Correct dx and dy, which are 0 for 1D images, to be 0.5. diff -r 06b23f224f52 -r cdb6bc186c42 scripts/plot/util/private/__go_draw_axes__.m --- a/scripts/plot/util/private/__go_draw_axes__.m Sun Dec 21 17:38:14 2014 -0500 +++ b/scripts/plot/util/private/__go_draw_axes__.m Tue Dec 16 17:25:47 2014 +0100 @@ -157,7 +157,7 @@ [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string"); fontspec = create_fontspec (f, s, gnuplot_term); fprintf (plot_stream, "set title \"%s\" %s %s %s;\n", - undo_string_escapes (tt), fontspec, colorspec, + undo_string_escapes (tt), fontspec, colorspec, __do_enhanced_option__ (enhanced, t)); endif endif @@ -513,6 +513,9 @@ img_ydata = img_ydata(1) + [0, rows(img_data)-1]; endif + x_origin = min (img_xdata); + y_origin = min (img_ydata); + [y_dim, x_dim] = size (img_data(:,:,1)); if (x_dim > 1) dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); @@ -520,6 +523,11 @@ x_dim = 2; img_data = [img_data, img_data]; dx = abs (img_xdata(2)-img_xdata(1)); + if (dx < 1) + ## Correct gnuplot string for 1-D images + dx = 0.5; + x_origin = 0.75; + endif endif if (y_dim > 1) dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); @@ -527,11 +535,13 @@ y_dim = 2; img_data = [img_data; img_data]; dy = abs (img_ydata(2)-img_ydata(1)); + if (dy < 1) + ## Correct gnuplot string for 1-D images + dy = 0.5; + y_origin = 0.75; + endif endif - x_origin = min (img_xdata); - y_origin = min (img_ydata); - if (ndims (img_data) == 3) data{data_idx} = permute (img_data, [3, 1, 2])(:); format = "1:2:3"; @@ -2131,7 +2141,7 @@ plot_stream, mirror, mono, axispos, tickdir, ticklength, fontname, fontspec, interpreter, scale, sgn, gnuplot_term) persistent warned_latex = false; - + ## Avoid emitting anything if the tics are empty, because this undoes the ## effect of the previous unset xtics and thereby adds back in the tics. if (isempty (tics)) @@ -2626,4 +2636,3 @@ axis_obj.tickdir); endif endfunction -