The bivariate_plot_df.py
allows users to create bivariate scatter plots with color classification based on specified criteria. This visualization technique is useful for exploring the relationship between two continuous variables in a dataset and understanding how they interact. bivariate_plot_raster.py
is for raster images similiar to biscale
package in R.
- Supports classification of dataframe or raster using quantiles or equal interval.
- Configurable plot aesthetics (labels, titles, sizes).
- Option to overlay shapefiles for additional context on raster bivariate plot.
- Customizable colormaps and figure size.
- Customizable legend generation to help interpret the bivariate classifications.
To use the function, you need to have Python and the required libraries installed.
- Python 3.x
- numpy
- matplotlib
- rasterio (may require prior
gdal
installation too) - geopandas
- os
You can install the necessary packages via pip:
pip install numpy pandas matplotlib rasterio geopandas
path = r'data\test.csv'
# Call the bivariate classification function using a continuous colormap
bivariate_plot_df(
path, 'ADF Statistic', 'Keener Z-Statistic',
style='quantile',
n_bins=5,
cmap_name='bwr',
alpha=0.7,
edgecolor='black',
plot_kwargs = {},
legend_kwargs={'legend_position': (1.10, 0.15), 'legend_size': 0.2, 'ticklabelsize': 10}
)
raster1_path = r'path/to/your/temperature_raster.TIF'
raster2_path = r'path/to/your/precipitation_raster.TIF'
shp_path = r'path/to/your/shapefile.shp'
bivariate_raster_plot(
raster1_path,
raster2_path,
shp_path,
n_bins=5,
style='quantile',
cmap_name='coolwarm',
legend_kwargs={'ticklabelsize': 10, 'labelsize': 10, 'y_label': 'Precipitation (mm)', 'x_label':'Temperature (°C)'}
)
If you'd like to contribute to this project, please fork the repository and submit a pull request with your changes. All contributions are welcome!
This project is licensed under the MIT License.