@@ -816,6 +816,189 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
816
816
arg_str = " " .join ([fname , build_arg_string (kwargs )])
817
817
lib .call_module ("plot" , arg_str )
818
818
819
+ @fmt_docstring
820
+ @use_alias (
821
+ A = "straight_line" ,
822
+ B = "frame" ,
823
+ C = "cmap" ,
824
+ D = "offset" ,
825
+ G = "color" ,
826
+ I = "intensity" ,
827
+ J = "projection" ,
828
+ Jz = "zscale" ,
829
+ JZ = "zsize" ,
830
+ L = "close" ,
831
+ N = "no_clip" ,
832
+ Q = "no_sort" ,
833
+ R = "region" ,
834
+ S = "style" ,
835
+ V = "verbose" ,
836
+ W = "pen" ,
837
+ X = "xshift" ,
838
+ Y = "yshift" ,
839
+ Z = "zvalue" ,
840
+ i = "columns" ,
841
+ l = "label" ,
842
+ p = "perspective" ,
843
+ t = "transparency" ,
844
+ )
845
+ @kwargs_to_strings (R = "sequence" , i = "sequence_comma" , p = "sequence" )
846
+ def plot3d (
847
+ self , x = None , y = None , z = None , data = None , sizes = None , direction = None , ** kwargs
848
+ ):
849
+ """
850
+ Plot lines, polygons, and symbols in 3-D
851
+
852
+ Takes a matrix, (x,y,z) triplets, or a file name as input and plots
853
+ lines, polygons, or symbols at those locations in 3-D.
854
+
855
+ Must provide either *data* or *x*, *y* and *z*.
856
+
857
+ If providing data through *x*, *y* and *z*, *color* can be a 1d array
858
+ that will be mapped to a colormap.
859
+
860
+ If a symbol is selected and no symbol size given, then plot3d will
861
+ interpret the fourth column of the input data as symbol size. Symbols
862
+ whose size is <= 0 are skipped. If no symbols are specified then the
863
+ symbol code (see *style* below) must be present as last column in the
864
+ input. If *style* is not used, a line connecting the data points will
865
+ be drawn instead. To explicitly close polygons, use *close*. Select a
866
+ fill with *color*. If *color* is set, *pen* will control whether the
867
+ polygon outline is drawn or not. If a symbol is selected, *color* and
868
+ *pen* determines the fill and outline/no outline, respectively.
869
+
870
+ Full option list at :gmt-docs:`plot3d.html`
871
+
872
+ {aliases}
873
+
874
+ Parameters
875
+ ----------
876
+ x/y/z : float or 1d arrays
877
+ The x, y, and z coordinates, or arrays of x, y and z coordinates of
878
+ the data points
879
+ data : str or 2d array
880
+ Either a data file name or a 2d numpy array with the tabular data.
881
+ Use option *columns* (i) to choose which columns are x, y, z,
882
+ color, and size, respectively.
883
+ sizes : 1d array
884
+ The sizes of the data points in units specified in *style* (S).
885
+ Only valid if using *x*, *y* and *z*.
886
+ direction : list of two 1d arrays
887
+ If plotting vectors (using ``style='V'`` or ``style='v'``), then
888
+ should be a list of two 1d arrays with the vector directions. These
889
+ can be angle and length, azimuth and length, or x and y components,
890
+ depending on the style options chosen.
891
+ {J}
892
+ zscale/zsize : float or str
893
+ Set z-axis scaling or z-axis size.
894
+ {R}
895
+ straight_line : bool or str
896
+ ``[m|p|x|y]``.
897
+ By default, geographic line segments are drawn as great circle
898
+ arcs. To draw them as straight lines, use *straight_line*.
899
+ Alternatively, add **m** to draw the line by first following a
900
+ meridian, then a parallel. Or append **p** to start following a
901
+ parallel, then a meridian. (This can be practical to draw a line
902
+ along parallels, for example). For Cartesian data, points are
903
+ simply connected, unless you append **x** or **y** to draw
904
+ stair-case curves that whose first move is along *x* or *y*,
905
+ respectively. **Note**: The **straight_line** option requires
906
+ constant *z*-coordinates.
907
+ {B}
908
+ {CPT}
909
+ offset : str
910
+ ``dx/dy[/dz]``.
911
+ Offset the plot symbol or line locations by the given amounts
912
+ *dx/dy*[*dz*] [Default is no offset].
913
+ {G}
914
+ intensity : float or bool
915
+ Provide an *intens* value (nominally in the -1 to +1 range) to
916
+ modulate the fill color by simulating illumination [None]. If
917
+ using ``intensity=True``, we will instead read *intens* from the
918
+ first data column after the symbol parameters (if given).
919
+ close : str
920
+ ``[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen]``.
921
+ Force closed polygons. Full documentation is at
922
+ :gmt-docs:`plot3d.html#l`.
923
+ no_clip : bool or str
924
+ ``[c|r]``.
925
+ Do NOT clip symbols that fall outside map border [Default plots
926
+ points whose coordinates are strictly inside the map border only].
927
+ The option does not apply to lines and polygons which are always
928
+ clipped to the map region. For periodic (360-longitude) maps we
929
+ must plot all symbols twice in case they are clipped by the
930
+ repeating boundary. ``no_clip=True`` will turn off clipping and not
931
+ plot repeating symbols. Use ``no_clip="r"`` to turn off clipping
932
+ but retain the plotting of such repeating symbols, or use
933
+ ``no_clip="c"`` to retain clipping but turn off plotting of
934
+ repeating symbols.
935
+ no_sort : bool
936
+ Turn off the automatic sorting of items based on their distance
937
+ from the viewer. The default is to sort the items so that items in
938
+ the foreground are plotted after items in the background.
939
+ style : str
940
+ Plot symbols. Full documentation is at :gmt-docs:`plot3d.html#s`.
941
+ {U}
942
+ {V}
943
+ {W}
944
+ {XY}
945
+ zvalue : str
946
+ ``value|file``.
947
+ Instead of specifying a symbol or polygon fill and outline color
948
+ via **color** and **pen**, give both a *value* via **zvalue** and a
949
+ color lookup table via **cmap**. Alternatively, give the name of a
950
+ *file* with one z-value (read from the last column) for each
951
+ polygon in the input data. To apply it to the fill color, use
952
+ ``color='+z'``. To apply it to the pen color, append **+z** to
953
+ **pen**.
954
+ label : str
955
+ Add a legend entry for the symbol or line being plotted.
956
+ {p}
957
+ {t}
958
+ *transparency* can also be a 1d array to set varying transparency
959
+ for symbols.
960
+
961
+ """
962
+ kwargs = self ._preprocess (** kwargs )
963
+
964
+ kind = data_kind (data , x , y , z )
965
+
966
+ extra_arrays = []
967
+ if "S" in kwargs and kwargs ["S" ][0 ] in "vV" and direction is not None :
968
+ extra_arrays .extend (direction )
969
+ if "G" in kwargs and not isinstance (kwargs ["G" ], str ):
970
+ if kind != "vectors" :
971
+ raise GMTInvalidInput (
972
+ "Can't use arrays for color if data is matrix or file."
973
+ )
974
+ extra_arrays .append (kwargs ["G" ])
975
+ del kwargs ["G" ]
976
+ if sizes is not None :
977
+ if kind != "vectors" :
978
+ raise GMTInvalidInput (
979
+ "Can't use arrays for sizes if data is matrix or file."
980
+ )
981
+ extra_arrays .append (sizes )
982
+
983
+ if "t" in kwargs and is_nonstr_iter (kwargs ["t" ]):
984
+ extra_arrays .append (kwargs ["t" ])
985
+ kwargs ["t" ] = ""
986
+
987
+ with Session () as lib :
988
+ # Choose how data will be passed in to the module
989
+ if kind == "file" :
990
+ file_context = dummy_context (data )
991
+ elif kind == "matrix" :
992
+ file_context = lib .virtualfile_from_matrix (data )
993
+ elif kind == "vectors" :
994
+ file_context = lib .virtualfile_from_vectors (
995
+ np .atleast_1d (x ), np .atleast_1d (y ), np .atleast_1d (z ), * extra_arrays
996
+ )
997
+
998
+ with file_context as fname :
999
+ arg_str = " " .join ([fname , build_arg_string (kwargs )])
1000
+ lib .call_module ("plot3d" , arg_str )
1001
+
819
1002
@fmt_docstring
820
1003
@use_alias (
821
1004
R = "region" ,
@@ -921,6 +1104,8 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
921
1104
@use_alias (
922
1105
R = "region" ,
923
1106
J = "projection" ,
1107
+ Jz = "zscale" ,
1108
+ JZ = "zsize" ,
924
1109
B = "frame" ,
925
1110
L = "map_scale" ,
926
1111
Td = "rose" ,
@@ -935,12 +1120,12 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
935
1120
@kwargs_to_strings (R = "sequence" , p = "sequence" )
936
1121
def basemap (self , ** kwargs ):
937
1122
"""
938
- Produce a basemap for the figure.
1123
+ Plot base maps and frames for the figure.
939
1124
940
- Several map projections are available, and the user may specify
941
- separate tick-mark intervals for boundary annotation, ticking, and
942
- [optionally] gridlines. A simple map scale or directional rose may also
943
- be plotted.
1125
+ Creates a basic or fancy basemap with axes, fill, and titles. Several
1126
+ map projections are available, and the user may specify separate
1127
+ tick-mark intervals for boundary annotation, ticking, and [optionally]
1128
+ gridlines. A simple map scale or directional rose may also be plotted.
944
1129
945
1130
At least one of the options *frame*, *map_scale*, *rose* or *compass*
946
1131
must be specified.
@@ -952,6 +1137,8 @@ def basemap(self, **kwargs):
952
1137
Parameters
953
1138
----------
954
1139
{J}
1140
+ zscale/zsize : float or str
1141
+ Set z-axis scaling or z-axis size.
955
1142
{R}
956
1143
{B}
957
1144
map_scale : str
0 commit comments