Mercurial > octave
changeset 24364:9cba59ee9564 stable
Simplify gnuplot toolkit scripts for image/non-image data plots (bug #52589).
* __gnuplot_draw_axes__.m: Drop the semicolon from the image data "with"
clause and remove lines of code that subtract that semicolon later. Move
the test for removing background and foreground rectangles prior to all
plot/splot commands and make it only dependent on any image present.
Eliminate conditions in which the fprintf() is identical after the above
changes.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Tue, 05 Dec 2017 17:12:08 -0600 |
parents | 1da659b26bec |
children | bb993ab9f012 ccedd8a29d3e |
files | scripts/plot/util/private/__gnuplot_draw_axes__.m |
diffstat | 1 files changed, 17 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Tue Dec 05 09:24:05 2017 -0800 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Tue Dec 05 17:12:08 2017 -0600 @@ -609,7 +609,7 @@ titlespec{data_idx} = "title \"\""; usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s", x_dim, y_dim, x_origin, y_origin, dx, dy, format); - withclause{data_idx} = sprintf ("with %s;", imagetype); + withclause{data_idx} = sprintf ("with %s", imagetype); case "line" if (strcmp (get (obj.parent, "type"), "hggroup")) @@ -1660,6 +1660,20 @@ fputs (plot_stream, "unset colorbox;\n"); if (have_data) + for i = 1:data_idx + ## Images can be obscured by background or foreground image + if (is_image_data (i)) + if (bg_is_set) + fputs (plot_stream, "if (GPVAL_TERM eq \"qt\") unset obj 1;\n"); + bg_is_set = false; + endif + if (fg_is_set) + fputs (plot_stream, "unset obj 2; \\\n"); + fg_is_set = false; + endif + break; + endif + endfor if (nd == 2) plot_cmd = "plot"; else @@ -1695,13 +1709,6 @@ fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, usingclause{1}, titlespec{1}, withclause{1}); elseif (is_image_data (1)) - if (numel (is_image_data) > 1 && is_image_data(2)) - ## Remove terminating semicolon - n = max (strfind (withclause{1}, ";")); - if (! isempty (n)) - withclause{1} = withclause{1}(1:n-1); - endif - endif fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, usingclause{1}, titlespec{1}, withclause{1}); else @@ -1713,41 +1720,8 @@ fprintf (plot_stream, ", \"-\" %s %s %s \\\n", usingclause{i}, titlespec{i}, withclause{i}); elseif (is_image_data (i)) - if (! is_image_data (i-1)) - fputs (plot_stream, "; "); - if (bg_is_set) - fputs (plot_stream, "if (GPVAL_TERM eq \"qt\") unset obj 1;\n"); - bg_is_set = false; - endif - if (fg_is_set) - fputs (plot_stream, "unset obj 2; \\\n"); - fg_is_set = false; - endif - if (numel (is_image_data) > i && is_image_data(i+1)) - ## Remove terminating semicolon - n = max (strfind (withclause{i}, ";")); - if (! isempty (n)) - withclause{i} = withclause{i}(1:n-1); - endif - endif - fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, - usingclause{i}, titlespec{i}, withclause{i}); - else - ## For consecutive images continue with the same plot command - fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", ",", - usingclause{i}, titlespec{i}, withclause{i}); - endif - elseif (is_image_data (i-1)) - if (bg_is_set) - fputs (plot_stream, "if (GPVAL_TERM eq \"qt\") unset obj 1;\n"); - bg_is_set = false; - endif - if (fg_is_set) - fputs (plot_stream, "unset obj 2; \\\n"); - fg_is_set = false; - endif - fprintf (plot_stream,"%s \"-\" binary format='%%float64' %s %s %s \\\n", - plot_cmd, usingclause{i}, titlespec{i}, withclause{i}); + fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", ",", + usingclause{i}, titlespec{i}, withclause{i}); else fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n", usingclause{i}, titlespec{i}, withclause{i});