@@ -1009,17 +1009,28 @@ def plot(self, gdf, attribute, p=0.05,
1009
1009
cmap = cmap ,
1010
1010
figsize = figsize )
1011
1011
return fig , axs
1012
-
1013
- def scatterplot (self , p = 0.05 , ** kwargs ):
1014
- """Plot Local Moran Scatterplot
1012
+
1013
+
1014
+ def scatterplot (self , zstandard = True , p = 0.05 ,
1015
+ ax = None , scatter_kwds = None , fitline_kwds = None ):
1016
+ """
1017
+ Moran Scatterplot with option of coloring of Local Moran Statistics
1015
1018
1016
1019
Parameters
1017
1020
----------
1018
1021
p : float, optional
1019
- The p-value threshold for significance. Points will
1020
- be colored by LISA and significance. Default=0.05
1021
- **kwargs : keyword arguments, optional
1022
- Keywords used for creating and designing the plot.
1022
+ If given, the p-value threshold for significance. Points will
1023
+ be colored by significance. By default it will not be colored.
1024
+ Default =None.
1025
+ ax : Matplotlib Axes instance, optional
1026
+ If given, the Moran plot will be created inside this axis.
1027
+ Default =None.
1028
+ scatter_kwds : keyword arguments, optional
1029
+ Keywords used for creating and designing the scatter points.
1030
+ Default =None.
1031
+ fitline_kwds : keyword arguments, optional
1032
+ Keywords used for creating and designing the moran fitline.
1033
+ Default =None.
1023
1034
1024
1035
Returns
1025
1036
-------
@@ -1030,6 +1041,24 @@ def scatterplot(self, p=0.05, **kwargs):
1030
1041
1031
1042
Examples
1032
1043
--------
1044
+ >>> import matplotlib.pyplot as plt
1045
+ >>> import geopandas as gpd
1046
+ >>> import libpysal.api as lp
1047
+ >>> from libpysal import examples
1048
+ >>> from esda.moran import Moran_Local
1049
+ Load data and calculate Moran Local statistics
1050
+ >>> link = examples.get_path('columbus.shp')
1051
+ >>> gdf = gpd.read_file(link)
1052
+ >>> y = gdf['HOVAL'].values
1053
+ >>> w = lp.Queen.from_dataframe(gdf)
1054
+ >>> w.transform = 'r'
1055
+ >>> moran_loc = Moran_Local(y, w)
1056
+ plot
1057
+ >>> moran_loc.scatterplot()
1058
+ >>> plt.show()
1059
+ customize plot
1060
+ >>> moran_loc.scatterplot(fitline_kwds=dict(color='#4393c3'))
1061
+ >>> plt.show()
1033
1062
"""
1034
1063
try :
1035
1064
import splot .esda
@@ -1038,13 +1067,16 @@ def scatterplot(self, p=0.05, **kwargs):
1038
1067
UserWarning )
1039
1068
raise e
1040
1069
1041
- fig , ax = splot .esda .moran_loc_scatterplot (self , p = p , ** kwargs )
1070
+ fig , ax = splot .esda .moran_loc_scatterplot (self , zstandard = zstandard , p = p ,
1071
+ ax = ax , scatter_kwds = scatter_kwds ,
1072
+ fitline_kwds = fitline_kwds )
1042
1073
return fig , ax
1043
1074
1044
1075
1045
- def LISA_map (self , gdf , p = 0.05 ,
1046
- legend = True , ** kwargs ):
1047
- """Plot LISA cluster map
1076
+ def lisa_map (self , gdf , p = 0.05 , ax = None ,
1077
+ legend = True , legend_kwds = None , ** kwargs ):
1078
+ """
1079
+ Plot LISA cluster map
1048
1080
1049
1081
Parameters
1050
1082
----------
@@ -1054,12 +1086,19 @@ def LISA_map(self, gdf, p=0.05,
1054
1086
provided `gdf`. (either using gdf.assign() or gdf.copy())
1055
1087
p : float, optional
1056
1088
The p-value threshold for significance. Points will
1057
- be colored by significance. Default =0.05
1089
+ be colored by significance.
1090
+ ax : matplotlib Axes instance, optional
1091
+ Axes in which to plot the figure in multiple Axes layout.
1092
+ Default = None
1058
1093
legend : boolean, optional
1059
1094
If True, legend for maps will be depicted. Default = True
1095
+ legend_kwds : dict, optional
1096
+ Dictionary to control legend formatting options. Example:
1097
+ ``legend_kwds={'loc': 'upper left', 'bbox_to_anchor': (0.92, 1.05)}``
1098
+ Default = None
1060
1099
**kwargs : keyword arguments, optional
1061
- Keywords used for creating and designing the plot.
1062
-
1100
+ Keywords designing and passed to geopandas.GeoDataFrame. plot() .
1101
+
1063
1102
Returns
1064
1103
-------
1065
1104
fig : matplotlip Figure instance
@@ -1069,6 +1108,24 @@ def LISA_map(self, gdf, p=0.05,
1069
1108
1070
1109
Examples
1071
1110
--------
1111
+ >>> import matplotlib.pyplot as plt
1112
+ >>> import geopandas as gpd
1113
+ >>> import libpysal.api as lp
1114
+ >>> from libpysal import examples
1115
+ >>> from esda.moran import Moran_Local
1116
+ Load data and calculate Moran Local statistics
1117
+ >>> link = examples.get_path('columbus.shp')
1118
+ >>> gdf = gpd.read_file(link)
1119
+ >>> y = gdf['HOVAL'].values
1120
+ >>> w = lp.Queen.from_dataframe(gdf)
1121
+ >>> w.transform = 'r'
1122
+ >>> moran_loc = Moran_Local(y, w)
1123
+ plot
1124
+ >>> moran_loc.lisa_map(gdf)
1125
+ >>> plt.show()
1126
+ customize plot
1127
+ >>> moran_loc.lisa_map(gdf, legend=False)
1128
+ >>> plt.show()
1072
1129
"""
1073
1130
try :
1074
1131
import splot .esda
@@ -1077,7 +1134,8 @@ def LISA_map(self, gdf, p=0.05,
1077
1134
UserWarning )
1078
1135
raise e
1079
1136
1080
- fig , ax = splot .esda .lisa_cluster (self , gdf , p = p , ** kwargs )
1137
+ fig , ax = splot .esda .lisa_cluster (self , gdf , p = p , ax = ax ,
1138
+ legend = legend , legend_kwds = legend_kwds , ** kwargs )
1081
1139
return fig , ax
1082
1140
1083
1141
0 commit comments