Mercurial > hg > octave-nkf
comparison scripts/plot/__go_draw_axes__.m @ 9729:3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 15 Oct 2009 21:43:34 +0200 |
parents | 303f862a896d |
children | 7161e9b41cf6 |
comparison
equal
deleted
inserted
replaced
9728:70925b11ba46 | 9729:3b7e644bb46d |
---|---|
520 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s", | 520 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s", |
521 rows(xdat), xaxisloc_using, yaxisloc_using); | 521 rows(xdat), xaxisloc_using, yaxisloc_using); |
522 endif | 522 endif |
523 endif | 523 endif |
524 | 524 |
525 [style, typ, with] = do_linestyle_command (obj, data_idx, mono, | 525 style = do_linestyle_command (obj, obj.color, data_idx, mono, |
526 plot_stream, errbars); | 526 plot_stream, errbars); |
527 | 527 |
528 withclause{data_idx} = sprintf ("with %s linestyle %d", | 528 withclause{data_idx} = sprintf ("with %s linestyle %d", |
529 style, data_idx); | 529 style{1}, data_idx); |
530 | |
531 if (length (style) > 1) | |
532 data_idx++; | |
533 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
534 parametric(data_idx) = parametric(data_idx - 1); | |
535 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
536 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
537 titlespec{data_idx} = "title \"\""; | |
538 usingclause{data_idx} = usingclause{data_idx - 1}; | |
539 data{data_idx} = data{data_idx - 1}; | |
540 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
541 style{2}, data_idx); | |
542 endif | |
543 if (length (style) > 2) | |
544 data_idx++; | |
545 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
546 parametric(data_idx) = parametric(data_idx - 1); | |
547 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
548 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
549 titlespec{data_idx} = "title \"\""; | |
550 usingclause{data_idx} = usingclause{data_idx - 1}; | |
551 data{data_idx} = data{data_idx - 1}; | |
552 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
553 style{3}, data_idx); | |
554 endif | |
530 | 555 |
531 case "patch" | 556 case "patch" |
532 cmap = parent_figure_obj.colormap; | 557 cmap = parent_figure_obj.colormap; |
533 [nr, nc] = size (obj.xdata); | 558 [nr, nc] = size (obj.xdata); |
534 | 559 |
863 data_idx++; | 888 data_idx++; |
864 is_image_data(data_idx) = false; | 889 is_image_data(data_idx) = false; |
865 parametric(data_idx) = false; | 890 parametric(data_idx) = false; |
866 have_cdata(data_idx) = true; | 891 have_cdata(data_idx) = true; |
867 have_3d_patch(data_idx) = false; | 892 have_3d_patch(data_idx) = false; |
868 [style, typ, with] = do_linestyle_command (obj, data_idx, | 893 style = do_linestyle_command (obj, obj.edgecolor, |
869 mono, plot_stream); | 894 data_idx, mono, |
895 plot_stream); | |
870 if (isempty (obj.keylabel)) | 896 if (isempty (obj.keylabel)) |
871 titlespec{data_idx} = "title \"\""; | 897 titlespec{data_idx} = "title \"\""; |
872 else | 898 else |
873 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); | 899 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); |
874 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); | 900 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); |
875 endif | 901 endif |
876 withclause{data_idx} = sprintf ("with pm3d linestyle %d", | 902 withclause{data_idx} = sprintf ("with pm3d linestyle %d", |
877 data_idx); | 903 data_idx); |
904 withpm3d = true; | |
905 pm3didx = data_idx; | |
878 | 906 |
879 xdat = obj.xdata; | 907 xdat = obj.xdata; |
880 ydat = obj.ydata; | 908 ydat = obj.ydata; |
881 zdat = obj.zdata; | 909 zdat = obj.zdata; |
882 cdat = obj.cdata; | 910 cdat = obj.cdata; |
936 || (isnumeric (obj.facecolor) | 964 || (isnumeric (obj.facecolor) |
937 && all (obj.facecolor == 1))); | 965 && all (obj.facecolor == 1))); |
938 hidden_removal = false; | 966 hidden_removal = false; |
939 fputs (plot_stream, "set style increment default;\n"); | 967 fputs (plot_stream, "set style increment default;\n"); |
940 if (flat_interp_edge && facecolor_none_or_white) | 968 if (flat_interp_edge && facecolor_none_or_white) |
941 withclause{data_idx} = "with line palette"; | 969 withpm3d = false; |
970 withclause{data_idx} = sprintf ("with %s palette", style {1}); | |
942 fputs (plot_stream, "unset pm3d\n"); | 971 fputs (plot_stream, "unset pm3d\n"); |
943 if (all (obj.facecolor == 1)) | 972 if (all (obj.facecolor == 1)) |
944 hidden_removal = true; | 973 hidden_removal = true; |
945 endif | 974 endif |
946 elseif (facecolor_none_or_white) | 975 elseif (facecolor_none_or_white) |
947 edgecol = obj.edgecolor; | |
948 if (mono) | |
949 colorspec = ""; | |
950 else | |
951 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", | |
952 round (255*edgecol)); | |
953 endif | |
954 if (all (obj.facecolor == 1)) | 976 if (all (obj.facecolor == 1)) |
955 hidden_removal = true; | 977 hidden_removal = true; |
956 endif | 978 endif |
957 fputs(plot_stream,"unset pm3d;\n"); | 979 fputs(plot_stream,"unset pm3d;\n"); |
958 fprintf (plot_stream, | |
959 "set style line %d %s lw %f;\n", | |
960 data_idx, colorspec, obj.linewidth); | |
961 fputs(plot_stream,"set style increment user;\n"); | 980 fputs(plot_stream,"set style increment user;\n"); |
962 withclause{data_idx} = sprintf("with line linestyle %d", data_idx); | 981 withpm3d = false; |
982 withclause{data_idx} = sprintf("with %s linestyle %d", | |
983 style{1}, data_idx); | |
963 fputs (plot_stream, "unset pm3d\n"); | 984 fputs (plot_stream, "unset pm3d\n"); |
964 endif | 985 endif |
965 | 986 |
966 if (doing_interp_color) | 987 if (doing_interp_color) |
967 ## "depthorder" interferes with interpolation of colors. | 988 ## "depthorder" interferes with interpolation of colors. |
982 obj.facealpha); | 1003 obj.facealpha); |
983 endif | 1004 endif |
984 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", | 1005 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", |
985 interp_str, dord); | 1006 interp_str, dord); |
986 else | 1007 else |
987 edgecol = obj.edgecolor; | |
988 if (ischar (obj.edgecolor)) | |
989 edgecol = [0, 0, 0]; | |
990 endif | |
991 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", | 1008 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", |
992 data_idx, interp_str, dord); | 1009 data_idx, interp_str, dord); |
993 | 1010 |
994 if (mono) | |
995 colorspec = ""; | |
996 else | |
997 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", | |
998 round (255*edgecol)); | |
999 endif | |
1000 fprintf (plot_stream, | |
1001 "set style line %d %s lw %f;\n", | |
1002 data_idx, colorspec, obj.linewidth); | |
1003 if (__gnuplot_has_feature__ ("transparent_surface") | 1011 if (__gnuplot_has_feature__ ("transparent_surface") |
1004 && isscalar (obj.facealpha)) | 1012 && isscalar (obj.facealpha)) |
1005 fprintf (plot_stream, | 1013 fprintf (plot_stream, |
1006 "set style fill transparent solid %f;\n", | 1014 "set style fill transparent solid %f;\n", |
1007 obj.facealpha); | 1015 obj.facealpha); |
1008 endif | 1016 endif |
1009 endif | 1017 endif |
1010 endif | 1018 endif |
1019 | |
1020 zz = []; | |
1021 if (length (style) > 1) | |
1022 len = 3 * xlen; | |
1023 zz = zeros (ylen, len); | |
1024 k = 1; | |
1025 for kk = 1:3:len | |
1026 zz(:,kk) = xdat(:,k); | |
1027 zz(:,kk+1) = ydat(:,k); | |
1028 zz(:,kk+2) = zdat(:,k); | |
1029 k++; | |
1030 endfor | |
1031 zz = zz.'; | |
1032 | |
1033 data_idx++; | |
1034 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1035 parametric(data_idx) = parametric(data_idx - 1); | |
1036 have_cdata(data_idx) = false; | |
1037 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1038 titlespec{data_idx} = "title \"\""; | |
1039 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1040 data{data_idx} = zz; | |
1041 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
1042 style{2}, data_idx); | |
1043 | |
1044 endif | |
1045 if (length (style) > 2) | |
1046 data_idx++; | |
1047 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1048 parametric(data_idx) = parametric(data_idx - 1); | |
1049 have_cdata(data_idx) = false; | |
1050 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1051 titlespec{data_idx} = "title \"\""; | |
1052 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1053 data{data_idx} = zz; | |
1054 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
1055 style{3}, data_idx); | |
1056 endif | |
1057 if (withpm3d && strncmp (style {1}, "linespoints", 11)) | |
1058 if (isempty(zz)) | |
1059 len = 3 * xlen; | |
1060 zz = zeros (ylen, len); | |
1061 k = 1; | |
1062 for kk = 1:3:len | |
1063 zz(:,kk) = xdat(:,k); | |
1064 zz(:,kk+1) = ydat(:,k); | |
1065 zz(:,kk+2) = zdat(:,k); | |
1066 k++; | |
1067 endfor | |
1068 zz = zz.'; | |
1069 endif | |
1070 data_idx++; | |
1071 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1072 parametric(data_idx) = parametric(data_idx - 1); | |
1073 have_cdata(data_idx) = false; | |
1074 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1075 titlespec{data_idx} = "title \"\""; | |
1076 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1077 data{data_idx} = zz; | |
1078 withclause{data_idx} = sprintf ("with points linestyle %d", | |
1079 pm3didx); | |
1080 endif | |
1011 endif | 1081 endif |
1012 | 1082 |
1013 case "text" | 1083 case "text" |
1014 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string"); | 1084 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string"); |
1015 fontspec = create_fontspec (f, s, gnuplot_term); | 1085 fontspec = create_fontspec (f, s, gnuplot_term); |
1361 else | 1431 else |
1362 fontspec = sprintf ("font \"%s,%d\"", f, s); | 1432 fontspec = sprintf ("font \"%s,%d\"", f, s); |
1363 endif | 1433 endif |
1364 endfunction | 1434 endfunction |
1365 | 1435 |
1366 function [style, typ, with] = do_linestyle_command (obj, idx, mono, | 1436 function style = do_linestyle_command (obj, linecolor, idx, mono, |
1367 plot_stream, errbars = "") | 1437 plot_stream, errbars = "") |
1438 style = {}; | |
1368 | 1439 |
1369 fprintf (plot_stream, "set style line %d default;\n", idx); | 1440 fprintf (plot_stream, "set style line %d default;\n", idx); |
1370 fprintf (plot_stream, "set style line %d", idx); | 1441 fprintf (plot_stream, "set style line %d", idx); |
1371 | 1442 |
1372 found_style = false; | 1443 found_style = false; |
1373 typ = NaN; | 1444 if (isnumeric (linecolor)) |
1374 with = ""; | 1445 color = linecolor; |
1375 | 1446 if (! mono) |
1376 if (isfield (obj, "color")) | 1447 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", |
1377 color = obj.color; | 1448 round (255*color)); |
1378 if (isnumeric (color)) | 1449 endif |
1379 if (! mono) | 1450 else |
1380 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | 1451 color = [0, 0, 0]; |
1381 round (255*color)); | |
1382 endif | |
1383 endif | |
1384 found_style = true; | |
1385 endif | 1452 endif |
1386 | 1453 |
1387 if (isfield (obj, "linestyle")) | 1454 if (isfield (obj, "linestyle")) |
1388 switch (obj.linestyle) | 1455 switch (obj.linestyle) |
1389 case "-" | 1456 case "-" |
1409 ## or the print command. Therefore, it is currently disabled in | 1476 ## or the print command. Therefore, it is currently disabled in |
1410 ## order to allow print (..., "-dashed") etc. to work correctly. | 1477 ## order to allow print (..., "-dashed") etc. to work correctly. |
1411 | 1478 |
1412 ## if (! isempty (lt)) | 1479 ## if (! isempty (lt)) |
1413 ## fprintf (plot_stream, " linetype %s", lt); | 1480 ## fprintf (plot_stream, " linetype %s", lt); |
1414 ## found_style = true; | |
1415 ## endif | 1481 ## endif |
1416 | 1482 |
1417 else | 1483 else |
1418 lt = ""; | 1484 lt = ""; |
1485 endif | |
1486 if (! isempty (errbars)) | |
1487 found_style = true; | |
1419 endif | 1488 endif |
1420 | 1489 |
1421 if (isfield (obj, "linewidth")) | 1490 if (isfield (obj, "linewidth")) |
1422 fprintf (plot_stream, " linewidth %f", obj.linewidth); | 1491 fprintf (plot_stream, " linewidth %f", obj.linewidth); |
1423 found_style = true; | 1492 found_style = true; |
1424 endif | 1493 endif |
1425 | 1494 |
1426 if (isfield (obj, "marker")) | 1495 if (isfield (obj, "marker")) |
1427 switch (obj.marker) | 1496 switch (obj.marker) |
1428 case "+" | 1497 case "+" |
1429 pt = "1"; | 1498 pt = pt2 = "1"; |
1430 case "o" | 1499 case "o" |
1431 pt = "6"; | 1500 pt = "6"; |
1501 pt2 = "7"; | |
1432 case "*" | 1502 case "*" |
1433 pt = "3"; | 1503 pt = pt2 = "3"; |
1434 case "." | 1504 case "." |
1435 pt = "0"; | 1505 pt = pt2 = "0"; |
1436 case "x" | 1506 case "x" |
1437 pt = "2"; | 1507 pt = pt2 = "2"; |
1438 case {"square", "s"} | 1508 case {"square", "s"} |
1439 pt = "5"; | 1509 pt = "4"; |
1510 pt2 = "5"; | |
1440 case {"diamond", "d"} | 1511 case {"diamond", "d"} |
1441 pt = "13"; | 1512 pt = "13"; |
1513 pt2 = "14"; | |
1442 case "^" | 1514 case "^" |
1443 pt = "9"; | 1515 pt = "8"; |
1516 pt2 = "9"; | |
1444 case "v" | 1517 case "v" |
1445 pt = "11"; | 1518 pt = "10"; |
1519 pt2 = "11"; | |
1446 case ">" | 1520 case ">" |
1521 ## FIXME missing point type | |
1447 pt = "8"; | 1522 pt = "8"; |
1523 pt2 = "9"; | |
1448 case "<" | 1524 case "<" |
1525 ## FIXME missing point type | |
1449 pt = "10"; | 1526 pt = "10"; |
1527 pt2 = "11"; | |
1450 case {"pentagram", "p"} | 1528 case {"pentagram", "p"} |
1451 pt = "4"; | 1529 ## FIXME missing point type |
1530 pt = pt2 = "3"; | |
1452 case {"hexagram", "h"} | 1531 case {"hexagram", "h"} |
1453 pt = "12"; | 1532 pt = pt2 = "3"; |
1454 case "none" | 1533 case "none" |
1455 pt = ""; | 1534 pt = pt2 = ""; |
1456 otherwise | 1535 otherwise |
1457 pt = ""; | 1536 pt = pt2 = ""; |
1458 endswitch | 1537 endswitch |
1459 if (! isempty (pt)) | |
1460 fprintf (plot_stream, " pointtype %s", pt); | |
1461 found_style = true; | |
1462 endif | |
1463 else | 1538 else |
1464 pt = ""; | 1539 pt = pt2 = ""; |
1465 endif | 1540 endif |
1466 | 1541 |
1542 if (! isempty (pt)) | |
1543 found_style = true; | |
1544 endif | |
1545 | |
1546 sidx = 1; | |
1467 if (isempty (errbars)) | 1547 if (isempty (errbars)) |
1468 style = "lines"; | |
1469 if (isempty (lt)) | 1548 if (isempty (lt)) |
1470 if (! isempty (pt)) | 1549 style {sidx} = ""; |
1471 style = "points"; | 1550 else |
1472 endif | 1551 style {sidx} = "lines"; |
1473 elseif (! isempty (pt)) | 1552 endif |
1474 style = "linespoints"; | 1553 |
1475 endif | 1554 facesame = true; |
1476 | 1555 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") |
1477 if (isfield (obj, "markersize")) | 1556 && !strncmp (obj.markerfacecolor, "none", 4)) |
1478 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | 1557 if (strncmp (obj.markerfacecolor, "auto", 4) |
1479 found_style = true; | 1558 || ! isnumeric (obj.markerfacecolor) |
1559 || (isnumeric (obj.markerfacecolor) | |
1560 && isequal (color, obj.markerfacecolor))) | |
1561 style {sidx} = strcat (style{sidx}, "points"); | |
1562 if (! isempty (pt2)) | |
1563 fprintf (plot_stream, " pointtype %s", pt2); | |
1564 endif | |
1565 if (isfield (obj, "markersize")) | |
1566 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1567 endif | |
1568 else | |
1569 facesame = false; | |
1570 if (! found_style) | |
1571 fputs (plot_stream, " default"); | |
1572 endif | |
1573 fputs (plot_stream, ";\n"); | |
1574 if (! isempty (style {sidx})) | |
1575 sidx ++; | |
1576 idx ++; | |
1577 else | |
1578 fputs (plot_stream, ";\n"); | |
1579 endif | |
1580 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1581 fprintf (plot_stream, "set style line %d", idx); | |
1582 if (isnumeric (obj.markerfacecolor) && ! mono) | |
1583 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1584 round (255*obj.markerfacecolor)); | |
1585 endif | |
1586 style {sidx} = "points"; | |
1587 if (! isempty (pt2)) | |
1588 fprintf (plot_stream, " pointtype %s", pt2); | |
1589 endif | |
1590 if (isfield (obj, "markersize")) | |
1591 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1592 endif | |
1593 endif | |
1594 endif | |
1595 if (isfield (obj, "markeredgecolor") | |
1596 && !strncmp (obj.markeredgecolor, "none", 4)) | |
1597 if (facesame && (strncmp (obj.markeredgecolor, "auto", 4) | |
1598 || ! isnumeric (obj.markeredgecolor) | |
1599 || (isnumeric (obj.markeredgecolor) | |
1600 && isequal (color, obj.markeredgecolor)))) | |
1601 if (! isequal (pt, pt2) && sidx == 1 && ((length (style {sidx}) == 5 | |
1602 && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx}))) | |
1603 style {sidx} = strcat (style{sidx}, "points"); | |
1604 if (! isempty (pt)) | |
1605 fprintf (plot_stream, " pointtype %s", pt); | |
1606 endif | |
1607 if (isfield (obj, "markersize")) | |
1608 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1609 endif | |
1610 endif | |
1611 else | |
1612 if (! found_style) | |
1613 fputs (plot_stream, " default"); | |
1614 endif | |
1615 fputs (plot_stream, ";\n"); | |
1616 if (!isempty (style {sidx})) | |
1617 sidx ++; | |
1618 idx ++; | |
1619 else | |
1620 fputs (plot_stream, ";\n"); | |
1621 endif | |
1622 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1623 fprintf (plot_stream, "set style line %d", idx); | |
1624 if (! mono) | |
1625 if (strncmp (obj.markeredgecolor, "auto", 4)) | |
1626 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1627 round (255*color)); | |
1628 elseif (isnumeric (obj.markeredgecolor) && ! mono) | |
1629 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1630 round (255*obj.markeredgecolor)); | |
1631 endif | |
1632 endif | |
1633 style {sidx} = "points"; | |
1634 if (! isempty (pt)) | |
1635 fprintf (plot_stream, " pointtype %s", pt); | |
1636 endif | |
1637 if (isfield (obj, "markersize")) | |
1638 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1639 endif | |
1640 endif | |
1480 endif | 1641 endif |
1481 else | 1642 else |
1482 style = errbars; | 1643 style{1} = errbars; |
1483 found_style = true; | 1644 endif |
1484 endif | 1645 |
1485 | 1646 if (! found_style && isempty (style {1})) |
1486 if (! found_style) | |
1487 fputs (plot_stream, " default"); | 1647 fputs (plot_stream, " default"); |
1488 endif | 1648 endif |
1489 | 1649 |
1490 fputs (plot_stream, ";\n"); | 1650 fputs (plot_stream, ";\n"); |
1491 | 1651 |