~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to scripts/plot/__go_draw_axes__.m

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Weber
  • Date: 2008-08-12 22:28:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080812222801-b3myaxymt2k5m709
Tags: 1:3.0.1-6lenny1
Allow libhdf5-openmpi-dev to satisfy Octave's hdf5 dependency (closes:
#494139)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
## Copyright (C) 2005, 2007 John W. Eaton
 
1
## Copyright (C) 2005, 2007, 2008 John W. Eaton
2
2
##
3
3
## This file is part of Octave.
4
4
##
33
33
 
34
34
    ## Set axis properties here?
35
35
    pos = [0, 0, 1, 1];
36
 
    if (strcmp (axis_obj.activepositionproperty, "outerposition"))
 
36
    if (strcmpi (axis_obj.activepositionproperty, "outerposition"))
37
37
      ymirror = true;
38
38
      if (! isempty (axis_obj.outerposition))
39
39
        pos = axis_obj.outerposition;
49
49
      endif
50
50
    endif
51
51
 
52
 
    if (! strcmp (axis_obj.__colorbar__, "none"))
 
52
    if (! strcmpi (get (h, "__colorbar__"), "none"))
53
53
      [pos, cbox_orient, cbox_size, cbox_origin, cbox_mirror] = ...
54
 
          gnuplot_postion_colorbox (pos, axis_obj.__colorbar__);
 
54
          gnuplot_position_colorbox (pos, get (h, "__colorbar__"), axis_obj);
55
55
    endif
56
56
 
57
57
    fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
64
64
      fputs (plot_stream, "set size noratio;\n");
65
65
    endif
66
66
 
67
 
    fputs (plot_stream, "set pm3d explicit;\n");
68
67
    fputs (plot_stream, "unset label;\n");
69
68
 
70
69
    if (! isempty (axis_obj.title))
79
78
        else
80
79
          fontspec = sprintf ("font \"%s,%d\"", f, s);
81
80
        endif
82
 
        fprintf (plot_stream, "set title \"%s\" %s;\n",
83
 
                 undo_string_escapes (tt), fontspec);
 
81
        fprintf (plot_stream, "set title \"%s\" %s %s;\n",
 
82
                 undo_string_escapes (tt), fontspec,
 
83
                 __do_enhanced_option__ (enhanced, t));
84
84
      endif
85
85
    endif
86
86
 
100
100
          fontspec = sprintf ("font \"%s,%d\"", f, s);
101
101
        endif
102
102
        if (strcmpi (axis_obj.xaxislocation, "top"))
103
 
          fprintf (plot_stream, "set x2label \"%s\" %s %s",
104
 
                   undo_string_escapes (tt), colorspec, fontspec);
 
103
          fprintf (plot_stream, "set x2label \"%s\" %s %s %s",
 
104
                   undo_string_escapes (tt), colorspec, fontspec,
 
105
                   __do_enhanced_option__ (enhanced, t));
105
106
        else
106
 
          fprintf (plot_stream, "set xlabel \"%s\" %s %s",
107
 
                   undo_string_escapes (tt), colorspec, fontspec);
 
107
          fprintf (plot_stream, "set xlabel \"%s\" %s %s %s",
 
108
                   undo_string_escapes (tt), colorspec, fontspec,
 
109
                   __do_enhanced_option__ (enhanced, t));
108
110
        endif
109
111
        if (have_newer_gnuplot)
110
112
          ## Rotation of xlabel not yet support by gnuplot as of 4.2, but
136
138
          fontspec = sprintf ("font \"%s,%d\"", f, s);
137
139
        endif
138
140
        if (strcmpi (axis_obj.yaxislocation, "right"))
139
 
          fprintf (plot_stream, "set y2label \"%s\" %s %s",
140
 
                   undo_string_escapes (tt), colorspec, fontspec);
 
141
          fprintf (plot_stream, "set y2label \"%s\" %s %s %s",
 
142
                   undo_string_escapes (tt), colorspec, fontspec,
 
143
                   __do_enhanced_option__ (enhanced, t));
141
144
        else
142
 
          fprintf (plot_stream, "set ylabel \"%s\" %s %s",
143
 
                   undo_string_escapes (tt), colorspec, fontspec);
 
145
          fprintf (plot_stream, "set ylabel \"%s\" %s %s %s",
 
146
                   undo_string_escapes (tt), colorspec, fontspec,
 
147
                   __do_enhanced_option__ (enhanced, t));
144
148
        endif
145
149
        if (have_newer_gnuplot)
146
150
          fprintf (plot_stream, " rotate by %f;\n", angle);
168
172
        else
169
173
          fontspec = sprintf ("font \"%s,%d\"", f, s);
170
174
        endif
171
 
        fprintf (plot_stream, "set zlabel \"%s\" %s %s",
172
 
                 undo_string_escapes (tt), colorspec, fontspec);
 
175
        fprintf (plot_stream, "set zlabel \"%s\" %s %s %s",
 
176
                 undo_string_escapes (tt), colorspec, fontspec,
 
177
                 __do_enhanced_option__ (enhanced, t));
173
178
        if (have_newer_gnuplot)
174
179
          ## Rotation of zlabel not yet support by gnuplot as of 4.2, but
175
180
          ## there is no message about it.
285
290
    yautoscale = strcmpi (axis_obj.ylimmode, "auto");
286
291
    zautoscale = strcmpi (axis_obj.zlimmode, "auto");
287
292
    cautoscale = strcmpi (axis_obj.climmode, "auto");
 
293
    cdatadirect = false;
288
294
 
289
295
    kids = axis_obj.children;
290
296
 
314
320
 
315
321
    [view_cmd, view_fcn, view_zoom] = image_viewer ();
316
322
    use_gnuplot_for_images = (ischar (view_fcn)
317
 
                              && strcmp (view_fcn, "gnuplot_internal"));
 
323
                              && strcmpi (view_fcn, "gnuplot_internal"));
318
324
 
319
325
    ximg_data = {};
320
326
    ximg_data_idx = 0;
331
337
 
332
338
          if (use_gnuplot_for_images)
333
339
 
 
340
            if (strcmpi (obj.cdatamapping, "direct"))
 
341
              cdatadirect = true;
 
342
            endif
334
343
            fputs (plot_stream, "set border front;\n");
335
344
            data_idx++;
336
345
            is_image_data(data_idx) = true;
387
396
            tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot));
388
397
            titlespec{data_idx} = strcat ("title \"", tmp, "\"");
389
398
          endif
390
 
          [style, typ, with] = do_linestyle_command (obj, data_idx,
391
 
                                                     mono, plot_stream);
392
399
          usingclause{data_idx} = "";
393
 
          if (have_newer_gnuplot || isnan (typ))
394
 
            withclause{data_idx} = sprintf ("with %s linestyle %d",
395
 
                                            style, data_idx);
396
 
          else
397
 
            withclause{data_idx} = sprintf ("with %s linetype %d",
398
 
                                            style, typ);
399
 
          endif
 
400
          errbars = "";
400
401
          if (nd == 3)
401
402
            xdat = obj.xdata(:);
402
403
            ydat = obj.ydata(:);
454
455
                endif
455
456
                data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]';
456
457
                usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)";
457
 
                withclause{data_idx} = "with xyerrorbars";
 
458
                errbars = "xyerrorbars";
458
459
              else
459
460
                data{data_idx} = [xdat, ydat, ylo, yhi]';
460
461
                usingclause{data_idx} = "using ($1):($2):($3):($4)";
461
 
                withclause{data_idx} = "with yerrorbars";
 
462
                errbars = "yerrorbars";
462
463
              endif
463
464
            elseif (xerr)
464
465
              if (isempty (xldat))
473
474
              endif
474
475
              data{data_idx} = [xdat, ydat, xlo, xhi]';
475
476
              usingclause{data_idx} = "using ($1):($2):($3):($4)";
476
 
              withclause{data_idx} = "with xerrorbars";
 
477
              errbars = "xerrorbars";
477
478
            else
478
479
              data{data_idx} = [xdat, ydat]';
479
480
              usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s",
480
481
                                              xaxisloc_using, yaxisloc_using);
481
482
            endif
482
483
          endif
 
484
 
 
485
          [style, typ, with] = do_linestyle_command (obj, data_idx, mono,
 
486
                                                     plot_stream, errbars);
 
487
 
 
488
          if (have_newer_gnuplot || isnan (typ))
 
489
            withclause{data_idx} = sprintf ("with %s linestyle %d",
 
490
                                            style, data_idx);
 
491
          else
 
492
            withclause{data_idx} = sprintf ("with %s linetype %d",
 
493
                                            style, typ);
 
494
          endif
 
495
 
483
496
          if (! (have_newer_gnuplot || isempty (with)))
484
497
            if (isempty (withclause{data_idx}))
485
498
              withclause{data_idx} = sprintf ("with %s", with);
495
508
 
496
509
         if (! isempty (obj.cdata))
497
510
           cdat = obj.cdata;
 
511
           if (strcmpi (obj.cdatamapping, "direct"))
 
512
             cdatadirect = true;
 
513
           endif
498
514
         else
499
515
           cdat = [];
500
516
         endif
562
578
                       color = cmap(r, :);
563
579
                     endif
564
580
                   elseif (strncmp (obj.facecolor, "interp", 6))
565
 
                     warning ("\"interp\" not supported, using 1st entry of cdata")
 
581
                     warning ("\"interp\" not supported, using 1st entry of cdata");
566
582
                     r = 1 + round ((size (cmap, 1) - 1) * ccol(1));
567
583
                     r = max (1, min (r, size (cmap, 1)));
568
584
                     color = cmap(r,:);
586
602
                 withclause{data_idx} = sprintf ("with filledcurve %s",
587
603
                                                 colorspec);
588
604
               else
589
 
                 if (isequal (color, [0,0,0]))
590
 
                   typ = -1;
591
 
                 elseif (isequal (color, [1,0,0]))
592
 
                   typ = 1;
593
 
                 elseif (isequal (color, [0,1,0]))
594
 
                   typ = 2;
595
 
                 elseif (isequal (color, [0,0,1]))
596
 
                   typ = 3;
597
 
                 elseif (isequal (color, [1,0,1]))
598
 
                   typ = 4;
599
 
                 elseif (isequal (color, [0,1,1]))
600
 
                   typ = 5;
601
 
                 elseif (isequal (color, [1,1,1]))
602
 
                   typ = -1;
603
 
                 elseif (isequal (color, [1,1,0]))
604
 
                   typ = 7;
605
 
                 else
606
 
                   typ = -1;
607
 
                 endif
 
605
                 typ = get_old_gnuplot_color (color);
608
606
                 withclause{data_idx} = sprintf ("with filledcurve lt %d", typ);
609
607
               endif
610
608
               data{data_idx} = [xcol, ycol]';
623
621
             usingclause{data_idx} = "";
624
622
 
625
623
             if (isfield (obj, "markersize"))
626
 
               mdat = obj.markersize;
 
624
               mdat = obj.markersize / 6;
627
625
             endif
628
626
 
629
627
             if (isfield (obj, "edgecolor"))
655
653
                     color = cmap(r, :);
656
654
                   endif
657
655
                 elseif (strncmp (obj.edgecolor, "interp", 6))
658
 
                   warning ("\"interp\" not supported, using 1st entry of cdata")
 
656
                   warning ("\"interp\" not supported, using 1st entry of cdata");
659
657
                   r = 1 + round ((size (cmap, 1) - 1) * ccol(1));
660
658
                   r = max (1, min (r, size (cmap, 1)));
661
659
                   color = cmap(r,:);
688
686
               lt = "";
689
687
             endif
690
688
 
 
689
             if (isfield (obj, "linewidth"))
 
690
               if (have_newer_gnuplot)
 
691
                 lw = sprintf("linewidth %f", obj.linewidth);
 
692
               else
 
693
                 lw = sprintf("lw %f", obj.linewidth);
 
694
               endif
 
695
             else
 
696
               lw  = "";
 
697
             endif
 
698
 
691
699
             if (isfield (obj, "marker"))
692
700
               if (isfield (obj, "marker"))
693
701
                 switch (obj.marker)
738
746
 
739
747
             if (isfield (obj, "markersize"))
740
748
               if (length (mdat) == nc)
741
 
                 m = mdat(i);
 
749
                 m = mdat(i) / 6;
742
750
               else
743
 
                 m = mdat;
 
751
                 m = mdat / 6;
744
752
               endif
745
753
               if (! strcmpi (style, "lines"))
746
754
                 if (have_newer_gnuplot)
762
770
                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
763
771
                                      round (255*color));
764
772
               endif
765
 
               withclause{data_idx} = sprintf ("with %s %s %s %s %s",
766
 
                                               style, pt, lt, ps, colorspec);
 
773
               withclause{data_idx} = sprintf ("with %s %s %s %s %s %s",
 
774
                                               style, lw, pt, lt, ps, 
 
775
                                               colorspec);
767
776
             else
768
 
               if (isequal (color, [0,0,0]))
769
 
                 typ = -1;
770
 
               elseif (isequal (color, [1,0,0]))
771
 
                 typ = 1;
772
 
               elseif (isequal (color, [0,1,0]))
773
 
                 typ = 2;
774
 
               elseif (isequal (color, [0,0,1]))
775
 
                 typ = 3;
776
 
               elseif (isequal (color, [1,0,1]))
777
 
                 typ = 4;
778
 
               elseif (isequal (color, [0,1,1]))
779
 
                 typ = 5;
780
 
               elseif (isequal (color, [1,1,1]))
781
 
                 typ = -1;
782
 
               elseif (isequal (color, [1,1,0]))
783
 
                 typ = 7;
784
 
               else
785
 
                 typ = -1;
786
 
               endif
787
 
               withclause{data_idx} = sprintf ("with %s %s %s lt %d", 
788
 
                                               style, pt, ps, typ);
 
777
               typ = get_old_gnuplot_color (color);
 
778
               withclause{data_idx} = sprintf ("with %s %s %s %s lt %d", 
 
779
                                               style, lw, pt, ps, typ);
789
780
             endif
790
781
 
791
782
             if (nd == 3)
875
866
              data{data_idx} = zz.';
876
867
            endif
877
868
            usingclause{data_idx} = "using ($1):($2):($3):($4)";
878
 
            ## fputs (plot_stream, "unset parametric;\n");
 
869
            ## fputs (plot_stream, "unset parametric;\n");
879
870
 
880
871
            ## Interpolation does not work for flat surfaces (e.g. pcolor)
881
872
            ## and color mapping --> currently set empty.
888
879
            facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4)
889
880
                                       || (isnumeric (obj.facecolor)
890
881
                                           && all (obj.facecolor == 1)));
891
 
            if (strncmp (obj.facecolor, "none", 4))
892
 
              hidden_removal = false;
893
 
            else
894
 
              if (isnan (hidden_removal))
895
 
                hidden_removal = true;
896
 
              endif
897
 
            endif
898
 
            
 
882
            hidden_removal = false;
 
883
            fputs (plot_stream, "set style increment default;\n");
899
884
            if (flat_interp_edge && facecolor_none_or_white)
900
885
              withclause{data_idx} = "with line palette";
 
886
              fputs (plot_stream, "unset pm3d\n");
 
887
              if (all (obj.facecolor == 1))
 
888
                hidden_removal = true;
 
889
              endif
 
890
            elseif (facecolor_none_or_white)
 
891
              edgecol = obj.edgecolor;
 
892
              if (have_newer_gnuplot)
 
893
                if (mono)
 
894
                  colorspec = "";
 
895
                else
 
896
                  colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"",
 
897
                                 round (255*edgecol));
 
898
                endif
 
899
                if (all (obj.facecolor == 1))
 
900
                  hidden_removal = true;
 
901
                endif
 
902
                fputs(plot_stream,"unset pm3d;\n");
 
903
                fprintf (plot_stream,
 
904
                         "set style line %d %s lw %f;\n",
 
905
                         data_idx, colorspec, obj.linewidth);
 
906
                fputs(plot_stream,"set style increment user;\n");
 
907
              else
 
908
                typ = get_old_gnuplot_color (edgecol);
 
909
                fprintf (plot_stream,
 
910
                         "set style line %d lt %d lw %f;\n",
 
911
                         data_idx, typ, obj.linewidth);
 
912
              endif
 
913
              withclause{data_idx} = sprintf("with line linestyle %d", data_idx);
 
914
              fputs (plot_stream, "unset pm3d\n");
901
915
            endif
902
916
 
903
917
            if (have_newer_gnuplot)
916
930
              else
917
931
                edgecol = obj.edgecolor;
918
932
                if (ischar (obj.edgecolor))
919
 
                  edgecol = [0,0,0];
 
933
                  edgecol = [0, 0, 0];
920
934
                endif
921
935
                fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", 
922
936
                         data_idx, interp_str, dord);
932
946
                           "set style line %d %s lw %f;\n",
933
947
                           data_idx, colorspec, obj.linewidth);
934
948
                else
935
 
                  if (isequal (edgecol, [0,0,0]))
936
 
                    typ = -1;
937
 
                  elseif (isequal (edgecol, [1,0,0]))
938
 
                    typ = 1;
939
 
                  elseif (isequal (edgecol, [0,1,0]))
940
 
                    typ = 2;
941
 
                  elseif (isequal (edgecol, [0,0,1]))
942
 
                    typ = 3;
943
 
                  elseif (isequal (edgecol, [1,0,1]))
944
 
                    typ = 4;
945
 
                  elseif (isequal (edgecol, [0,1,1]))
946
 
                    typ = 5;
947
 
                  elseif (isequal (edgecol, [1,1,1]))
948
 
                    typ = -1;
949
 
                  elseif (isequal (edgecol, [1,1,0]))
950
 
                    typ = 7;
951
 
                  else
952
 
                    typ = -1;
953
 
                  endif
 
949
                  typ = get_old_gnuplot_color (edgecol);
954
950
                  fprintf (plot_stream,
955
951
                           "set style line %d lt %d lw %f;\n",
956
952
                           data_idx, typ, obj.linewidth);
984
980
 
985
981
          if (nd == 3)
986
982
            fprintf (plot_stream,
987
 
                     "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s front %s;\n",
 
983
                     "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n",
988
984
                     undo_string_escapes (label), units, lpos(1),
989
 
                     lpos(2), lpos(3), halign, angle, fontspec, colorspec);
 
985
                     lpos(2), lpos(3), halign, angle, fontspec,
 
986
                     __do_enhanced_option__ (enhanced, obj), colorspec);
990
987
          else
991
988
            fprintf (plot_stream,
992
 
                     "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s front %s;\n",
 
989
                     "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n",
993
990
                     undo_string_escapes (label), units,
994
 
                     lpos(1), lpos(2), halign, angle, fontspec, colorspec);
 
991
                     lpos(1), lpos(2), halign, angle, fontspec,
 
992
                     __do_enhanced_option__ (enhanced, obj), colorspec);
995
993
          endif
996
994
 
997
995
        otherwise
1001
999
 
1002
1000
    endfor
1003
1001
 
 
1002
    ## This is need to prevent warnings for rotations in 3D plots, while
 
1003
    ## allowing colorbars with contours..
 
1004
    if (nd == 2 || data_idx > 1)
 
1005
      fputs (plot_stream, "set pm3d implicit;\n");
 
1006
    else
 
1007
      fputs (plot_stream, "set pm3d explicit;\n");
 
1008
    endif
 
1009
 
1004
1010
    if (isnan(hidden_removal) || hidden_removal)
1005
1011
      fputs (plot_stream, "set hidden3d;\n");
1006
1012
    else
1043
1049
      fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir);
1044
1050
    endif
1045
1051
 
 
1052
    cmap = parent_figure_obj.colormap;    
 
1053
    cmap_sz = rows(cmap);
1046
1054
    if (! any (isinf (clim)))
1047
 
      fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
 
1055
      if (cdatadirect)
 
1056
        fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz);
 
1057
      else
 
1058
        fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
 
1059
      endif
1048
1060
    endif
1049
1061
 
1050
1062
    if (strcmpi (axis_obj.box, "on"))
1058
1070
        fputs (plot_stream, "set border 895;\n");
1059
1071
      else
1060
1072
        if (strcmpi (axis_obj.yaxislocation, "right"))
1061
 
          fputs (plot_stream, "unset ytics; set y2tics nomirror\n");
 
1073
          fputs (plot_stream, "unset ytics; set y2tics %s nomirror\n",
 
1074
                 axis_obj.tickdir);
1062
1075
          if (strcmpi (axis_obj.xaxislocation, "top"))
1063
 
            fputs (plot_stream, "unset xtics; set x2tics nomirror\n");
 
1076
            fputs (plot_stream, "unset xtics; set x2tics %s nomirror\n",
 
1077
                 axis_obj.tickdir);
1064
1078
            fputs (plot_stream, "set border 12;\n");
1065
1079
          else
1066
 
            fputs (plot_stream, "unset x2tics; set xtics nomirror\n");
 
1080
            fputs (plot_stream, "unset x2tics; set xtics %s nomirror\n",
 
1081
                 axis_obj.tickdir);
1067
1082
            fputs (plot_stream, "set border 9;\n");
1068
1083
          endif
1069
1084
        else
1070
 
          fputs (plot_stream, "unset y2tics; set ytics nomirror\n");
 
1085
          fputs (plot_stream, "unset y2tics; set ytics %s nomirror\n",
 
1086
                 axis_obj.tickdir);
1071
1087
          if (strcmpi (axis_obj.xaxislocation, "top"))
1072
 
            fputs (plot_stream, "unset xtics; set x2tics nomirror\n");
 
1088
            fputs (plot_stream, "unset xtics; set x2tics %s nomirror\n",
 
1089
                   axis_obj.tickdir);
1073
1090
            fputs (plot_stream, "set border 6;\n");
1074
1091
          else
1075
 
            fputs (plot_stream, "unset x2tics; set xtics nomirror\n");
 
1092
            fputs (plot_stream, "unset x2tics; set xtics %s nomirror\n",
 
1093
                   axis_obj.tickdir);
1076
1094
            fputs (plot_stream, "set border 3;\n");
1077
1095
          endif
1078
1096
        endif
1081
1099
 
1082
1100
    if (strcmpi (axis_obj.visible, "off"))
1083
1101
      fputs (plot_stream, "unset border; unset tics\n");
 
1102
    else
 
1103
      fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth);
1084
1104
    endif
1085
1105
 
1086
1106
    if (strcmpi (axis_obj.key, "on"))
1151
1171
      endfor
1152
1172
    endif
1153
1173
 
1154
 
    cmap = parent_figure_obj.colormap;    
1155
 
    cmap_sz = rows(cmap);
1156
1174
    if (length(cmap) > 0)
1157
1175
      if (have_newer_gnuplot)
1158
1176
        fprintf (plot_stream,
1162
1180
                 "set palette file \"-\" binary record=%d using 1:2:3:4;\n",
1163
1181
                 cmap_sz);
1164
1182
        fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32");
 
1183
        fwrite (plot_stream, "\n");
1165
1184
      else
1166
1185
        fputs (plot_stream, "set palette defined (");
1167
1186
        for i = 1: cmap_sz
1178
1197
      endif
1179
1198
    endif
1180
1199
            
1181
 
    if (strcmp (axis_obj.__colorbar__, "none"))
 
1200
    if (strcmpi (get (h, "__colorbar__"), "none"))
1182
1201
      fputs (plot_stream, "unset colorbox;\n");
1183
1202
    else
1184
1203
      ## FIXME If cbox_mirror is true we want to invert the tic labels
1237
1256
 
1238
1257
endfunction
1239
1258
 
1240
 
function [style, typ, with] = do_linestyle_command (obj, idx, mono, plot_stream)
 
1259
function [style, typ, with] = do_linestyle_command (obj, idx, mono,
 
1260
                                                    plot_stream, errbars = "")
1241
1261
 
1242
1262
  persistent have_newer_gnuplot ...
1243
1263
    = compare_versions (__gnuplot_version__ (), "4.0", ">");
1260
1280
                   round (255*color));
1261
1281
        endif
1262
1282
      else
1263
 
        if (isequal (color, [0,0,0]))
1264
 
          typ = -1;
1265
 
        elseif (isequal (color, [1,0,0]))
1266
 
          typ = 1;
1267
 
        elseif (isequal (color, [0,1,0]))
1268
 
          typ = 2;
1269
 
        elseif (isequal (color, [0,0,1]))
1270
 
          typ = 3;
1271
 
        elseif (isequal (color, [1,0,1]))
1272
 
          typ = 4;
1273
 
        elseif (isequal (color, [0,1,1]))
1274
 
          typ = 5;
1275
 
        elseif (isequal (color, [1,1,1]))
1276
 
          typ = 6;
1277
 
        elseif (isequal (color, [1,1,0]))
1278
 
          typ = 7;
1279
 
        else
1280
 
          typ = 2;
1281
 
        endif
 
1283
        typ = get_old_gnuplot_color (color);
1282
1284
      endif
1283
1285
    endif
1284
1286
    found_style = true;
1372
1374
    pt = "";
1373
1375
  endif
1374
1376
 
1375
 
  style = "lines";
1376
 
  if (isempty (lt))
1377
 
    if (! isempty (pt))
1378
 
      style = "points";
 
1377
  if (isempty (errbars))
 
1378
    style = "lines";
 
1379
    if (isempty (lt))
 
1380
      if (! isempty (pt))
 
1381
        style = "points";
 
1382
      endif
 
1383
    elseif (! isempty (pt))
 
1384
      style = "linespoints";
1379
1385
    endif
1380
 
  elseif (! isempty (pt))
1381
 
    style = "linespoints";
1382
 
  endif
1383
1386
 
1384
 
  if (isfield (obj, "markersize"))
1385
 
    if (have_newer_gnuplot)
1386
 
      fprintf (plot_stream, " pointsize %f", obj.markersize);
1387
 
    else
1388
 
      if (! strcmpi (style, "lines"))
1389
 
        with = sprintf ("%s ps %f", with, obj.markersize);
 
1387
    if (isfield (obj, "markersize"))
 
1388
      if (have_newer_gnuplot)
 
1389
        fprintf (plot_stream, " pointsize %f", obj.markersize / 6);
 
1390
      else
 
1391
        if (! strcmpi (style, "lines"))
 
1392
          with = sprintf ("%s ps %f", with, obj.markersize / 6);
 
1393
        endif
1390
1394
      endif
 
1395
      found_style = true;
1391
1396
    endif
 
1397
  else
 
1398
    style = errbars;
1392
1399
    found_style = true;
1393
1400
  endif
1394
1401
 
1476
1483
function do_tics (obj, plot_stream, ymirror, mono)
1477
1484
  if (strcmpi (obj.xaxislocation, "top"))
1478
1485
    do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
1479
 
               obj.xcolor, "x2", plot_stream, true, mono, "border");
 
1486
               obj.xcolor, "x2", plot_stream, true, mono, "border",
 
1487
               obj.tickdir);
1480
1488
    do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
1481
 
               obj.xcolor, "x", plot_stream, true, mono, "border");
 
1489
               obj.xcolor, "x", plot_stream, true, mono, "border", "");
1482
1490
  elseif (strcmpi (obj.xaxislocation, "zero"))
1483
1491
    do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
1484
 
               obj.xcolor, "x", plot_stream, true, mono, "axis");
 
1492
               obj.xcolor, "x", plot_stream, true, mono, "axis",
 
1493
               obj.tickdir);
1485
1494
    do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
1486
 
               obj.xcolor, "x2", plot_stream, true, mono, "axis");
 
1495
               obj.xcolor, "x2", plot_stream, true, mono, "axis", "");
1487
1496
  else
1488
1497
    do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
1489
 
               obj.xcolor, "x", plot_stream, true, mono, "border");
 
1498
               obj.xcolor, "x", plot_stream, true, mono, "border",
 
1499
               obj.tickdir);
1490
1500
    do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
1491
 
               obj.xcolor, "x2", plot_stream, true, mono, "border");
 
1501
               obj.xcolor, "x2", plot_stream, true, mono, "border", "");
1492
1502
  endif
1493
1503
  if (strcmpi (obj.yaxislocation, "right"))
1494
1504
    do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
1495
 
               obj.ycolor, "y2", plot_stream, ymirror, mono, "border");
 
1505
               obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
 
1506
               obj.tickdir);
1496
1507
    do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
1497
 
               obj.ycolor, "y", plot_stream, ymirror, mono, "border");
 
1508
               obj.ycolor, "y", plot_stream, ymirror, mono, "border", "");
1498
1509
  elseif (strcmpi (obj.xaxislocation, "zero"))
1499
1510
    do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
1500
 
               obj.ycolor, "y", plot_stream, ymirror, mono, "axis");
 
1511
               obj.ycolor, "y", plot_stream, ymirror, mono, "axis",
 
1512
               obj.tickdir);
1501
1513
    do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
1502
 
               obj.ycolor, "y2", plot_stream, ymirror, mono, "axis");
 
1514
               obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", "");
1503
1515
  else
1504
1516
    do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
1505
 
               obj.ycolor, "y", plot_stream, ymirror, mono, "border");
 
1517
               obj.ycolor, "y", plot_stream, ymirror, mono, "border",
 
1518
               obj.tickdir);
1506
1519
    do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
1507
 
               obj.ycolor, "y2", plot_stream, ymirror, mono, "border");
 
1520
               obj.ycolor, "y2", plot_stream, ymirror, mono, "border", "");
1508
1521
  endif
1509
1522
  do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel,
1510
 
             obj.zcolor, "z", plot_stream, true, mono, "border");
 
1523
             obj.zcolor, "z", plot_stream, true, mono, "border",
 
1524
             obj.tickdir);
1511
1525
endfunction
1512
1526
 
1513
1527
function do_tics_1 (ticmode, tics, labelmode, labels, color, ax,
1514
 
                    plot_stream, mirror, mono, axispos)
 
1528
                    plot_stream, mirror, mono, axispos, tickdir)
1515
1529
  colorspec = get_text_colorspec (color, mono);
1516
1530
  if (strcmpi (ticmode, "manual"))
1517
1531
    if (isempty (tics))
1526
1540
        nlabels = numel (labels);
1527
1541
        fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
1528
1542
        if (mirror)
1529
 
          fprintf (plot_stream, "set %stics %s (", ax, axispos);
 
1543
          fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos);
1530
1544
        else
1531
 
          fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos);
 
1545
          fprintf (plot_stream, "set %stics %s %s nomirror (", ax,
 
1546
                   tickdir, axispos);
1532
1547
        endif
1533
1548
        labels = regexprep(labels, "%", "%%");
1534
1549
        for i = 1:ntics
1535
 
          fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i))
 
1550
          fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i));
1536
1551
          if (i < ntics)
1537
1552
            fputs (plot_stream, ", ");
1538
1553
          endif
1547
1562
    else
1548
1563
      fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
1549
1564
      if (mirror)
1550
 
        fprintf (plot_stream, "set %stics %s (", ax, axispos );
 
1565
        fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos );
1551
1566
      else
1552
 
        fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos);
 
1567
        fprintf (plot_stream, "set %stics %s %s nomirror (", ax, tickdir,
 
1568
                 axispos);
1553
1569
      endif
1554
1570
      fprintf (plot_stream, " %g,", tics(1:end-1));
1555
1571
      fprintf (plot_stream, " %g);\n", tics(end));
1557
1573
  else
1558
1574
    fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
1559
1575
    if (mirror)
1560
 
      fprintf (plot_stream, "set %stics %s %s;\n", ax, axispos, colorspec);
 
1576
      fprintf (plot_stream, "set %stics %s %s %s;\n", ax, axispos, tickdir,
 
1577
               colorspec);
1561
1578
    else
1562
 
      fprintf (plot_stream, "set %stics %s nomirror %s;\n", ax, 
1563
 
               axispos, colorspec);
 
1579
      fprintf (plot_stream, "set %stics %s %s nomirror %s;\n", ax, 
 
1580
               tickdir, axispos, colorspec);
1564
1581
    endif
1565
1582
  endif
1566
1583
endfunction
1577
1594
                           round (255*color));
1578
1595
    endif
1579
1596
  else
1580
 
    if (isequal (color, [0,0,0]))
1581
 
      typ = -1;
1582
 
    elseif (isequal (color, [1,0,0]))
1583
 
      typ = 1;
1584
 
    elseif (isequal (color, [0,1,0]))
1585
 
      typ = 2;
1586
 
    elseif (isequal (color, [0,0,1]))
1587
 
      typ = 3;
1588
 
    elseif (isequal (color, [1,0,1]))
1589
 
      typ = 4;
1590
 
    elseif (isequal (color, [0,1,1]))
1591
 
      typ = 5;
1592
 
    elseif (isequal (color, [1,1,1]))
1593
 
      typ = -1;
1594
 
    elseif (isequal (color, [1,1,0]))
1595
 
      typ = 7;
1596
 
    else
1597
 
      typ = -1;
1598
 
    endif
 
1597
    typ = get_old_gnuplot_color (color);
1599
1598
    colorspec = sprintf ("textcolor lt %d", typ);
1600
1599
  endif
1601
1600
endfunction
1602
1601
 
1603
1602
function [f, s, fnt, it, bld] = get_fontname_and_size (t)
1604
1603
  if (isempty (t.fontname))
1605
 
    fnt = "helvetica";
 
1604
    fnt = "Helvetica";
1606
1605
  else
1607
 
    fnt = tolower (t.fontname);
 
1606
    fnt = t.fontname;
1608
1607
  endif
1609
1608
  f = fnt;
1610
1609
  it = false;
1611
1610
  bld = false;
1612
 
  if (! isempty (t.fontweight) && strcmp (tolower (t.fontweight), "bold"))
 
1611
  if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold"))
1613
1612
    if (! isempty(t.fontangle)
1614
 
        && (strcmp (tolower (t.fontangle), "italic")
1615
 
            || strcmp (tolower (t.fontangle), "oblique")))
 
1613
        && (strcmpi (t.fontangle, "italic")
 
1614
            || strcmpi (t.fontangle, "oblique")))
1616
1615
      f = strcat (f, "-bolditalic");
1617
1616
      it = true;
1618
1617
      bld = true;
1621
1620
      bld = true;
1622
1621
    endif
1623
1622
  elseif (! isempty(t.fontangle)
1624
 
          && (strcmp (tolower (t.fontangle), "italic")
1625
 
              || strcmp (tolower (t.fontangle), "oblique")))
 
1623
          && (strcmpi (t.fontangle, "italic")
 
1624
              || strcmpi (t.fontangle, "oblique")))
1626
1625
    f = strcat (f, "-italic");
1627
1626
    it = true;
1628
1627
  endif
1640
1639
  if (strcmp (fld, "string"))
1641
1640
    [f, s, fnt, it, bld] = get_fontname_and_size (obj);
1642
1641
  else
1643
 
    f = "Helvectica";
 
1642
    f = "Helvetica";
1644
1643
    s = 10;
1645
1644
    fnt = f;
1646
1645
    it = false;
1862
1861
  sym.cong = '{/Symbol \100}';
1863
1862
  sym.Delta = '{/Symbol D}';
1864
1863
  sym.Phi = '{/Symbol F}';
1865
 
  sym.Gamma = '/Symbol G}';
 
1864
  sym.Gamma = '{/Symbol G}';
1866
1865
  sym.vartheta = '{/Symbol J}';
1867
1866
  sym.Lambda = '{/Symbol L}';
1868
1867
  sym.Pi = '{/Symbol P}';
1869
1868
  sym.Theta = '{/Symbol Q}';
1870
1869
  sym.Sigma = '{/Symbol S}';
1871
1870
  sym.varsigma = '{/Symbol V}';
1872
 
  sym.Omega = '{/Symbol O}';
 
1871
  sym.Omega = '{/Symbol W}';
1873
1872
  sym.Xi = '{/Symbol X}';
1874
1873
  sym.Psi = '{/Symbol Y}';
1875
1874
  sym.perp = '{/Symbol \136}';
1879
1878
  sym.delta = '{/Symbol d}';
1880
1879
  sym.epsilon = '{/Symbol e}';
1881
1880
  sym.phi = '{/Symbol f}';
1882
 
  sym.gamma = '/Symbol g}';
 
1881
  sym.gamma = '{/Symbol g}';
1883
1882
  sym.eta = '{/Symbol h}';
1884
1883
  sym.iota = '{/Symbol i}';
 
1884
  sym.varphi = '{/Symbol j}';
1885
1885
  sym.kappa = '{/Symbol k}';
1886
1886
  sym.lambda = '{/Symbol l}';
1887
1887
  sym.mu = '{/Symbol m}';
1939
1939
  sym.subset = '{/Symbol \314}';
1940
1940
  sym.subseteq = '{/Symbol \315}';
1941
1941
  sym.in = '{/Symbol \316}';
1942
 
  sym.langle = '{/Symbol \320}';
1943
 
  sym.rangle = '{/Symbol \320}';
 
1942
  sym.notin = '{/Symbol \317}';
 
1943
  sym.angle = '{/Symbol \320}';
 
1944
  sym.bigtriangledown = '{/Symbol \321}';
 
1945
  sym.langle = '{/Symbol \341}';
 
1946
  sym.rangle = '{/Symbol \361}';
1944
1947
  sym.nabla = '{/Symbol \321}';
 
1948
  sym.prod = '{/Symbol \325}';
1945
1949
  sym.surd = '{/Symbol \326}';
1946
1950
  sym.cdot = '{/Symbol \327}';
1947
1951
  sym.neg = '{/Symbol \330}';
1948
1952
  sym.wedge = '{/Symbol \331}';
1949
1953
  sym.vee = '{/Symbol \332}';
 
1954
  sym.Leftrightarrow = '{/Symbol \333}';
 
1955
  sym.Leftarrow = '{/Symbol \334}';
 
1956
  sym.Uparrow = '{/Symbol \335}';
 
1957
  sym.Rightarrow = '{/Symbol \336}';
 
1958
  sym.Downarrow = '{/Symbol \337}';
 
1959
  sym.diamond = '{/Symbol \340}';
1950
1960
  sym.copyright = '{/Symbol \343}';
1951
 
  sym.rfloor = '{/Symbol \353}';
 
1961
  sym.lfloor = '{/Symbol \353}';
1952
1962
  sym.lceil  = '{/Symbol \351}';
1953
 
  sym.lfloor = '{/Symbol \373}';
 
1963
  sym.rfloor = '{/Symbol \373}';
1954
1964
  sym.rceil  = '{/Symbol \371}';
1955
1965
  sym.int = '{/Symbol \362}';
1956
1966
endfunction
1957
1967
 
1958
 
function [pos, orient, sz, origin, mirr] = gnuplot_postion_colorbox (pos, cbox)
1959
 
  ## This is an emprically derived function that 
 
1968
function [pos, orient, sz, origin, mirr] = gnuplot_position_colorbox (pos, cbox, obj)
 
1969
  ## This is an emprically derived function that attempts to find a good
 
1970
  ## size for the colorbox even for subplots and strange aspect ratios.
1960
1971
 
1961
1972
  if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5))
1962
1973
    scl = pos([2,4]);
1971
1982
    endif
1972
1983
  endif
1973
1984
 
 
1985
  if (strcmpi (obj.dataaspectratiomode, "manual"))
 
1986
    sz = min(pos(3:4))([1,1]);
 
1987
    r = obj.dataaspectratio;
 
1988
    if (pos(3) > pos(4))
 
1989
      switch (cbox)
 
1990
        case {"north", "northoutside"}
 
1991
          off = 4 / 3 * [(pos(3) - pos(4)) ./ (r(2)/r(1)), pos(4) / pos(3) / 2];
 
1992
          sz = 2 * sz / 3;
 
1993
        case {"south", "southoutside"}
 
1994
          off = 4 / 3 * [(pos(3) - pos(4)) ./ (r(2)/r(1)), 0];
 
1995
          sz = 2 * sz / 3;
 
1996
        otherwise
 
1997
          off = [(pos(3) - pos(4)) ./ (r(2)/r(1)), 0];    
 
1998
      endswitch
 
1999
    else
 
2000
      switch (cbox)
 
2001
        case {"north", "northoutside"}
 
2002
          off = 1.5 * [0, (pos(4) - pos(3)) ./ (r(1) / r(2))];
 
2003
        case {"south", "southoutside"}
 
2004
          off = 0.5 * [0, (pos(4) - pos(3)) ./ (r(1) / r(2))];
 
2005
        otherwise
 
2006
          off = [0, (pos(4) - pos(3)) ./ (r(1) / r(2))];
 
2007
      endswitch
 
2008
    endif
 
2009
    off = off / 2;
 
2010
  else
 
2011
    sz = pos(3:4);
 
2012
    off = 0;
 
2013
  endif
1974
2014
  switch (cbox)
1975
2015
    case "northoutside"
1976
 
      sz = pos(3:4) - 0.08;
1977
 
      origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2);
 
2016
      sz = sz - 0.08;
 
2017
      origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2) + off;
1978
2018
      mirr = true;
1979
2019
      orient = "horizontal";
1980
2020
    case "north"
1981
 
      sz = pos(3:4) - 0.16;
1982
 
      origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2);
 
2021
      sz = sz - 0.16;
 
2022
      origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2) + off;
1983
2023
      mirr = false;
1984
2024
      orient = "horizontal";
1985
2025
    case "southoutside"
1986
 
      sz = pos(3:4) - 0.08;
1987
 
      origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2);
 
2026
      sz = sz - 0.08;
 
2027
      origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2) + off;
1988
2028
      mirr = false;
1989
2029
      orient = "horizontal";
1990
2030
    case "south"
1991
 
      sz = pos(3:4) - 0.16;
1992
 
      origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2);
 
2031
      sz = sz - 0.16;
 
2032
      origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2) + off;
1993
2033
      mirr = true;
1994
2034
      orient = "horizontal";
1995
2035
    case "eastoutside"
1996
 
      sz = pos(3:4) - 0.08;
1997
 
      origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2);
 
2036
      sz = sz - 0.08;
 
2037
      origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2) + off;
1998
2038
      mirr = false;
1999
2039
      orient = "vertical";
2000
2040
    case "east"
2001
 
      sz = pos(3:4) - 0.16;
2002
 
      origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2);
 
2041
      sz = sz - 0.16;
 
2042
      origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2) + off;
2003
2043
      mirr = true;
2004
2044
      orient = "vertical";
2005
2045
    case "westoutside"
2006
 
      sz = pos(3:4) - 0.08;
2007
 
      origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2);
 
2046
      sz = sz - 0.08;
 
2047
      origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2) + off;
2008
2048
      mirr = true;
2009
2049
      orient = "vertical";
2010
2050
    case "west"
2011
 
      sz = pos(3:4) - 0.16;
2012
 
      origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2);
 
2051
      sz = sz - 0.16;
 
2052
      origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2) + off;
2013
2053
      mirr = false;
2014
2054
      orient = "vertical";
2015
2055
  endswitch
2023
2063
  endif
2024
2064
 
2025
2065
endfunction
 
2066
 
 
2067
function retval = __do_enhanced_option__ (enhanced, obj)
 
2068
  retval = "";
 
2069
  if (enhanced)
 
2070
    if (strcmpi (obj.interpreter, "none"))
 
2071
      retval = "noenhanced";
 
2072
    else
 
2073
      retval = "enhanced";
 
2074
    endif
 
2075
  endif
 
2076
endfunction
 
2077
 
 
2078
function typ = get_old_gnuplot_color (color)
 
2079
  if (isequal (color, [0, 0, 0]))
 
2080
    typ = -1;
 
2081
  elseif (isequal (color, [1, 0, 0]))
 
2082
    typ = 1;
 
2083
  elseif (isequal (color, [0, 1, 0]))
 
2084
    typ = 2;
 
2085
  elseif (isequal (color, [0, 0, 1]))
 
2086
    typ = 3;
 
2087
  elseif (isequal (color, [1, 0, 1]))
 
2088
    typ = 4;
 
2089
  elseif (isequal (color, [0, 1, 1]))
 
2090
    typ = 5;
 
2091
  elseif (isequal (color, [1, 1, 1]))
 
2092
    typ = -1;
 
2093
  elseif (isequal (color, [1, 1, 0]))
 
2094
    typ = 7;
 
2095
  else
 
2096
    typ = -1;
 
2097
  endif
 
2098
endfunction