### Install and Use pre-commit Hook Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Installs the 'pre-commit' tool and its hook for the proplot repository. This framework automates code style and formatting checks before each commit, helping maintain code consistency across the project. It requires 'pre-commit' to be installed and then configured for the repository. ```bash pip install --user pre-commit pre-commit install ``` -------------------------------- ### Build Proplot Documentation Locally (Bash) Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Commands to build the proplot documentation locally. This involves navigating to the 'docs' directory, installing dependencies using 'environment.yml', and running the 'make html' command. The built documentation will be available in 'docs/_build/html'. ```bash cd docs # Install dependencies to the base conda environment.. conda env update -f environment.yml # ...or create a new conda environment # conda env create -n proplot-dev --file docs/environment.yml # source activate proplot-dev # Create HTML documentation make html ``` -------------------------------- ### Install Proplot in Editable Mode (Bash) Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Command to install proplot in editable mode using pip. This allows changes made to the source code to be immediately reflected without needing to reinstall the package, which is useful for development. ```bash pip install -e . ``` -------------------------------- ### Run Proplot Tests with Coverage Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Executes all project tests using 'pytest' and generates a code coverage report for the 'proplot' source files. This command is essential for ensuring code quality and identifying any regressions introduced by new changes. It requires 'coverage' and 'pytest' to be installed. ```bash coverage run --source proplot -m py.test ``` -------------------------------- ### Import Local Proplot Copy Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Demonstrates how to import a local copy of the proplot library for development. This ensures that changes made locally are reflected immediately, bypassing the installed PyPI version. It prints the file path of the imported proplot module to verify. ```python import proplot print(proplot.__file__) ``` -------------------------------- ### Use Journal-Specific Figure Sizes in ProPlot Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates how to create figures with dimensions pre-configured for specific academic journals using ProPlot. Examples include setting sizes for AGU single-column and Nature double-column figures. ```python import proplot as pplt import numpy as np # AGU single column figure fig, ax = pplt.subplot(figsize='agu1') # 95mm x 115mm # Nature double column figure fig, ax = pplt.subplot(figsize='nat2') # 183mm width ``` -------------------------------- ### Apply Styles with use_style() in Proplot Source: https://context7.com/proplot-dev/proplot/llms.txt Shows how to apply matplotlib stylesheets to individual axes or entire figures using `use_style()`. The example iterates through different styles, applying them to subplots and plotting data. Dependencies include `proplot` and `numpy`. ```python import proplot as pplt import numpy as np fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=2, share=False) state = np.random.RandomState(51423) data = state.rand(10, 5) # Apply different styles to different axes styles = ['ggplot', 'seaborn', '538', 'bmh'] for ax, style in zip(axs, styles): ax.format(style=style, title=style) ax.plot(data, linewidth=3) ax.format(xlabel='X', ylabel='Y') axs.format(suptitle='Multiple styles demo') # Or set style globally # pplt.use_style('seaborn') ``` -------------------------------- ### Control Handle Settings in Proplot Legend Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces `handle_kw` to `~proplot.axes.Axes.legend` for optionally controlling handle settings that may conflict with frame settings. For example, `handle_kw={'edgecolor': 'k'}`. ```python ax.legend(handle_kw={'edgecolor': 'k'}) ``` -------------------------------- ### Figure and Axes Instantiation with Format Keywords Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Proplot now permits passing 'format' keywords, such as `suptitle`, `xcolor`, and `xticks`, directly when instantiating figures and axes. This simplifies the initialization process. ```python pplt.figure(suptitle='Super title') ``` ```python fig.add_subplot(111, xcolor='gray', xticks=10) ``` -------------------------------- ### Build and Package for PyPI Release Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Removes previous build artifacts and then builds the source distribution (sdist) and wheel binary distribution for the package. These commands are necessary to prepare the package for uploading to the Python Package Index (PyPI). ```bash # Remove previous build products and build the package rm -r dist build *.egg-info python setup.py sdist bdist_wheel ``` -------------------------------- ### Clone Repository and Set Up Branch for Contributions (Bash) Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Steps to clone the proplot GitHub repository, set up the upstream remote, and create a new branch for development. This is a standard workflow for contributing to open-source projects using Git. ```bash git clone git@github.com:YOUR_GITHUB_USERNAME/proplot.git cd proplot git remote add upstream git@github.com:lukelbd/proplot.git git checkout -b your-branch-name master ``` -------------------------------- ### Create Pull Request Configuration Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Provides a template for the configuration file used when creating a pull request on GitHub. It specifies the source fork and branch, as well as the base fork and branch for the merge. ```text head-fork: YOUR_GITHUB_USERNAME/proplot compare: your-branch-name base-fork: lukelbd/proplot base: master ``` -------------------------------- ### Enhanced Plotting with `PlotAxes` and Data Integration Source: https://context7.com/proplot-dev/proplot/llms.txt Illustrates the use of Proplot's enhanced axes class, which offers improved plotting methods and better integration with data structures like pandas DataFrames and xarray DataArrays. Examples include automatic axis labeling from pandas index and columns, and creating 2D plots with automatic colorbar generation. ```python import proplot as pplt import numpy as np import pandas as pd # Sample data dates = pd.date_range('2020-01-01', periods=100) df = pd.DataFrame({ 'A': np.random.randn(100).cumsum(), 'B': np.random.randn(100).cumsum(), 'C': np.random.randn(100).cumsum() }, index=dates) fig, axs = pplt.subplots(ncols=2, refwidth=3, share=False) # Automatic xlabel/ylabel from pandas axs[0].plot(df) axs[0].format(title='Automatic formatting', legend='ul') # 2D plotting with automatic colorbar state = np.random.RandomState(51423) data = state.rand(20, 20).cumsum(axis=0) m = axs[1].contourf(data, cmap='Spectral_r', levels=12) axs[1].format(title='2D contourf plot') axs[1].colorbar(m, loc='r', label='Cumulative sum') fig.format(suptitle='Enhanced plotting demo') ``` -------------------------------- ### Commit Changes with pre-commit Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Standard git commands for committing changes after they have been reviewed and potentially modified by the 'pre-commit' hook. Commit messages should be concise and use the imperative mood. ```bash git commit -a -m "" git push -u ``` -------------------------------- ### Manage ProPlot and Matplotlib Settings with rc Source: https://context7.com/proplot-dev/proplot/llms.txt Shows how to manage global and contextual configuration settings using ProPlot's `rc` object. This includes updating global settings, applying temporary context-specific settings with `rc.context()`, resetting to defaults, and saving settings to a configuration file. ```python import proplot as pplt import numpy as np # Update global settings (persists across figures) pplt.rc.metacolor = 'gray6' pplt.rc.update({'fontname': 'Source Sans Pro', 'fontsize': 11}) pplt.rc['figure.facecolor'] = 'gray3' # Temporary context-specific settings with pplt.rc.context({'suptitle.size': 13}, toplabelcolor='gray6'): fig, axs = pplt.subplots(ncols=2, figwidth=6) state = np.random.RandomState(51423) data = np.cumsum(state.rand(100, 7) - 0.5, axis=0) cycle = pplt.get_colors('grays', 6) + ['red'] for ax in axs: ax.plot(data, linewidth=3, cycle=cycle) axs.format( xlabel='xlabel', ylabel='ylabel', suptitle='RC settings demo' ) # Reset to defaults pplt.rc.reset() # Save current settings to ~/.proplotrc # pplt.rc.save() ``` -------------------------------- ### Format Changelog Entry Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Specifies the format for adding new entries to the 'CHANGELOG.rst' file. Each entry should include a description of the change, the associated pull request number, and the author's name. This ensures a consistent and informative changelog. ```text * (:pr:``) by ``_. ``` -------------------------------- ### Checkout Master and Pull Latest Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Fetches the latest changes from the 'master' branch. This is done to ensure that the release is based on the most up-to-date code before tagging and pushing. ```bash git checkout master git pull ``` -------------------------------- ### Colormap Construction and Manipulation Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Enhances colormap creation by allowing direct HSL component specification and list-based application of alpha, luminance, and saturation. It also introduces convenient shorthands for color channels and new colormaps. ```python from proplot import constructor # Create colormap from HSL components cmap1 = constructor.Colormap(hue=0.5, saturation=0.8, luminance=0.6) # Apply alpha, luminance, saturation to components cmap2 = constructor.Colormap(list_of_cmaps, alpha=[0.5, 0.7], luminance=0.9) # Using shorthands cmap3 = constructor.Colormap(h=0.2, s=0.5, l=0.8) # Add seaborn colormaps proplot.rc.update({'cmap.flare': 'Flare', 'cmap.crest': 'Crest'}) ``` -------------------------------- ### Local Proplot Configuration for Axes and Figures Source: https://github.com/proplot-dev/proplot/blob/master/docs/configuration.rst Shows how to apply settings locally to a specific axes or figure using the `format` method. This allows for fine-grained control without altering global settings. ```python import proplot as pplt fig, ax = pplt.subplots() # Apply settings directly to axes ax.format(name1=value1, name2=value2) # Apply settings via rc_kw dictionary for axes ax.format(rc_kw={'name1': value1, 'name2': value2}) ``` -------------------------------- ### Tag Release and Push to Origin Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Tags the current commit with a specific version number and pushes the tag to the remote 'origin' repository. This marks the release point in the git history and makes it available on GitHub. ```bash git tag -a vX.Y.Z -m "Version X.Y.Z" git push origin master --tags ``` -------------------------------- ### Proplot Style Argument Documentation Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Improves the documentation for style-type arguments like `lw`, `linewidth`, etc., on `~proplot.axes.PlotAxes` commands. ```python ax.plot(..., lw=2, linewidth=3) ``` -------------------------------- ### Create Figure and Subplots with Proplot Source: https://github.com/proplot-dev/proplot/blob/master/docs/usage.rst Demonstrates two primary methods for creating figures and subplots using proplot. The first creates a figure with all subplots at once, while the second involves creating an empty figure and adding subplots subsequently. These methods are inspired by matplotlib's subplot creation functions and include proplot-specific enhancements like auto_layout. ```python fig, axs = pplt.subplots(...) ``` ```python fig = pplt.figure(...) axs = fig.add_subplots(...) # add several subplots ax = fig.add_subplot(...) # add a single subplot # axs = fig.subplots(...) # shorthand # ax = fig.subplot(...) # shorthand ``` -------------------------------- ### Update Changelog and Commit Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Stages and commits the updated 'CHANGELOG.rst' file as part of the release preparation. This ensures that the changelog accurately reflects the changes included in the new release. ```bash git add CHANGELOG.rst git commit -m 'Update changelog' ``` -------------------------------- ### Add Queue Keyword for Colorbar and Legend Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces a `queue` keyword for `colorbar` and `legend` to support workflows where handles are successively added to a specific location, facilitating more complex legend and colorbar construction. ```Python leg = ax.legend(..., queue='upper right') leg.add_handle(...) # Adds handle to the specified location ``` -------------------------------- ### Create Figures with ProPlot's subplots() Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates creating multi-panel figures with automatic grid layouts using ProPlot's `subplots()` function. It shows simple 2x2 grids, complex layouts defined by arrays, subplot access, and formatting multiple subplots simultaneously. ```python import proplot as pplt import numpy as np # Create a simple 2x2 grid fig, axs = pplt.subplots(ncols=2, nrows=2, figwidth=6, refwidth=2) # Create a complex subplot layout using array notation # 0 = empty space, numbers = subplot positions array = [ [1, 1, 2, 2], [0, 3, 3, 0], ] fig, axs = pplt.subplots(array, refwidth=1.8, span=False) # Access subplots via 1D or 2D indexing axs[0].plot([1, 2, 3], [1, 4, 2]) # First subplot axs[1, 0].plot([1, 2, 3], [2, 3, 1]) # Second row, first column # Format multiple subplots at once axs.format( xlabel='X axis', ylabel='Y axis', suptitle='Multi-panel figure' ) ``` -------------------------------- ### Local Proplotrc File Support Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Enables ProPlot to recognize local `proplotrc` files in addition to the traditional hidden `.proplotrc` files. This offers more flexibility in project-specific configuration. ```bash # Place your ProPlot configuration in a file named 'proplotrc' # in the current directory or a parent directory. # Example proplotrc content: # rc.update({'axes.labelsize': '10pt'}) # rc.update({'figure.facecolor': 'lightgray'}) ``` -------------------------------- ### Create Release Branch Source: https://github.com/proplot-dev/proplot/blob/master/CONTRIBUTING.rst Creates a new git branch for a specific release version. This is the first step in the release procedure, ensuring that the versioning is isolated before merging into the main branch. ```bash git checkout -b release-vX.Y.Z ``` -------------------------------- ### Temporary Proplot Configuration with Context Manager Source: https://github.com/proplot-dev/proplot/blob/master/docs/configuration.rst Illustrates how to temporarily modify settings using the `pplt.rc.context` context manager. Settings are reverted to their original values upon exiting the `with` block. ```python import proplot as pplt # Using context manager with keyword arguments with pplt.rc.context(name1=value1, name2=value2): fig, ax = pplt.subplots() # Using context manager with a dictionary with pplt.rc.context({'name1': value1, 'name2': value2}): fig, ax = pplt.subplots() ``` -------------------------------- ### Global Proplot Configuration Source: https://github.com/proplot-dev/proplot/blob/master/docs/configuration.rst Demonstrates how to change global settings in Proplot using dot notation or dictionary-like assignment. Settings are applied to the `pplt.rc` object, which manages both Matplotlib and Proplot configurations. ```python import proplot as pplt # Using dot notation pplt.rc.name = value # Using dictionary-like assignment pplt.rc['name'] = value # Using update with keyword arguments pplt.rc.update(name1=value1, name2=value2) # Using update with a dictionary pplt.rc.update({'name1': value1, 'name2': value2}) ``` -------------------------------- ### Support Aliases in Cycle Constructor Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Extends `proplot.constructor.Cycle` to support standard aliases like 'ls', 'linestyle', and 'linestyles' for specifying line styles, enhancing usability. ```Python from proplot import Cycle my_cycle = Cycle(color='Blues', ls=['-', '--', ':']) my_cycle = Cycle(color='Reds', linestyle=['-', '--', ':']) ``` -------------------------------- ### Style Figures and Axes with ProPlot's format() Method Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates the unified `format()` method in ProPlot for styling figures and axes. It covers setting super titles, subplot labels (a-b-c), titles in various positions, row/column labels, axis properties like labels and scales, and tick customization. ```python import proplot as pplt import numpy as np fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=2, share=False) state = np.random.RandomState(51423) data = (state.rand(60, 5) - 0.5).cumsum(axis=0) axs[0].plot(data, linewidth=1.5) # Format all subplots with comprehensive styling axs.format( # Super title and subplot labels suptitle='Format command demo', abc='A.', # Automatic a-b-c labels abcloc='ul', # Upper left # Multiple title positions title='Main', ltitle='Left', rtitle='Right', ultitle='Upper Left', urtitle='Upper Right', # Row and column labels toplabels=('Column 1', 'Column 2'), leftlabels=('Row 1', 'Row 2'), # Axis properties xlabel='xaxis', ylabel='yaxis', xscale='log', xlim=(1, 10), ylim=(-3, 3), # Tick customization xticks=1, yticks=pplt.arange(-3, 3), yticklabels=('a', 'bb', 'c', 'dd', 'e', 'ff', 'g'), ytickloc='both', xtickdir='inout', ygridminor=True ) ``` -------------------------------- ### Create Single Subplot Figures with ProPlot's subplot() Source: https://context7.com/proplot-dev/proplot/llms.txt Illustrates how to create figures with a single subplot using ProPlot's `subplot()` function, which accepts matplotlib-like syntax. Includes generating sample data, plotting, and saving the figure. ```python import proplot as pplt import numpy as np # Create single subplot fig, ax = pplt.subplot( suptitle='Single subplot', xlabel='x axis', ylabel='y axis' ) # Generate sample data and plot state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) ax.plot(data, lw=2) # Save figure fig.save('~/figure.pdf') ``` -------------------------------- ### Offset Title and ABC Label Placement Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Allows placing the main title and a-b-c labels in the same location by offsetting them from each other. The padding between them is controlled by the new `abc.titlepad` rc setting. ```Python ax.set_title('Main Title') ax.set_label('A') # The labels will be offset automatically based on abc.titlepad ``` -------------------------------- ### Manage Subplot Grids with SubplotGrid in Proplot Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates how to use `SubplotGrid` for efficient access and formatting of multiple subplots. It shows formatting by row, column, specific subsets, iteration for plotting, and global formatting of the entire grid. Dependencies include `proplot` and `numpy`. ```python import proplot as pplt import numpy as np fig, axs = pplt.subplots(ncols=3, nrows=2, refwidth=1.5, span=False) state = np.random.RandomState(51423) # Format by row axs[0, :].format(facecolor='lightblue', title='Row 1') # Format by column axs[:, 0].format(ylabel='Left column') # Format specific subset axs[1, 1:].format(facecolor='lightcoral') # Iterate and plot for i, ax in enumerate(axs): data = (state.rand(30, 3) - 0.5).cumsum(axis=0) ax.plot(data, lw=1.5) ax.format(title=f'Subplot {i+1}') # Format all at once axs.format( xlabel='X axis', abc='a)', abcloc='ul', suptitle='SubplotGrid formatting' ) ``` -------------------------------- ### Load Proplot Colors from Unextended Files Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Permits loading color names from files that do not have a '.txt' extension, removing a previously unnecessary restriction. ```python proplot.config.register_colors('mycolors') ``` -------------------------------- ### Proplot First Import Warning Improvement Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Enhances the universal 'rebuilding font cache' warning message displayed when new users import Proplot for the first time. ```python import proplot as pplt # First time import triggers enhanced message ``` -------------------------------- ### Import Proplot Library Source: https://github.com/proplot-dev/proplot/blob/master/docs/usage.rst Imports the proplot library with the conventional 'pplt' alias. This import adds new colormaps, property cycles, color names, and fonts to matplotlib. It is recommended for users interested in leveraging these enhanced features. ```python import proplot as pplt ``` -------------------------------- ### Simplify plot formatting with proplot.axes.Axes.format Source: https://github.com/proplot-dev/proplot/blob/master/docs/why.rst Demonstrates how to use the `proplot.axes.Axes.format` command to concisely modify plot settings like axis labels, titles, and limits. It contrasts this with the more verbose Matplotlib approach using multiple setter methods and rc_context. ```python import proplot as pplt fig, axs = pplt.subplots(ncols=2) axs.format(color='gray', linewidth=1) axs.format(xlim=(0, 100), xticks=10, xtickminor=True, xlabel='foo', ylabel='bar') ``` ```python import matplotlib.pyplot as plt import matplotlib.ticker as mticker import matplotlib as mpl with mpl.rc_context(rc={'axes.linewidth': 1, 'axes.edgecolor': 'gray'}): fig, axs = plt.subplots(ncols=2, sharey=True) axs[0].set_ylabel('bar', color='gray') for ax in axs: ax.set_xlim(0, 100) ax.xaxis.set_major_locator(mticker.MultipleLocator(10)) ax.tick_params(width=1, color='gray', labelcolor='gray') ax.tick_params(axis='x', which='minor', bottom=True) ax.set_xlabel('foo', color='gray') ``` -------------------------------- ### Colormap Construction with `pplt.Colormap` Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates creating custom colormaps using various methods: from color names, existing colormaps with modifications (e.g., `left`, `right` parameters), reversing colormaps, concatenating multiple colormaps, and sampling colormaps to generate color lists. These custom colormaps can then be used in plotting functions like `contourf`. ```python import proplot as pplt import numpy as np # Create colormap from color names cmap = pplt.Colormap('red', 'white', 'blue', name='custom_div') # Create colormap from existing cmap with modifications cmap = pplt.Colormap('viridis', left=0.1, right=0.9) # Reverse a colormap cmap = pplt.Colormap('Reds_r') # Concatenate colormaps cmap = pplt.Colormap('Blues', 'Reds', name='blue_red') # Sample the colormap colors = cmap(np.linspace(0, 1, 10)) # Use in plotting fig, axs = pplt.subplots(ncols=2, refwidth=2.5) state = np.random.RandomState(51423) data = state.rand(20, 20).cumsum(axis=0) m = axs[0].contourf(data, cmap='Fire', levels=10) axs[0].format(title='Built-in Fire colormap') m = axs[1].contourf(data, cmap=cmap, levels=10) axs[1].format(title='Custom colormap') fig.colorbar(m, loc='b', label='Values') ``` -------------------------------- ### Set Default Backend with Basemap RCParam Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces the `basemap` rcParam for changing the default plotting backend. This allows users to globally set their preferred backend, such as Cartopy or Basemap. ```Python proplot.rc['basemap'] = 'cartopy' # or proplot.rc['basemap'] = 'basemap' ``` -------------------------------- ### Color Cycle Generation with `pplt.Cycle` Source: https://context7.com/proplot-dev/proplot/llms.txt Shows how to generate color cycles for use in line plots. Cycles can be created from existing colormaps with specified number of colors (`N`) and luminance filtering (`left`), or directly from a list of color names. The generated cycle can be applied to plots using the `cycle` keyword argument. ```python import proplot as pplt import numpy as np # Create cycle from colormap cycle = pplt.Cycle('viridis', N=5) # Create cycle with luminance filtering cycle = pplt.Cycle('magma', left=0.2, N=7) # Create cycle from color names cycle = pplt.Cycle('red', 'blue', 'green', 'orange') # Use in plotting fig, ax = pplt.subplot(refwidth=4) state = np.random.RandomState(51423) data = (state.rand(50, 5) - 0.5).cumsum(axis=0) ax.plot(data, linewidth=2, cycle=cycle) ax.format( xlabel='X', ylabel='Y', title='Custom color cycle', legend='ul', labels=['Series 1', 'Series 2', 'Series 3', 'Series 4', 'Series 5'] ) ``` -------------------------------- ### Color Normalization with `pplt.Norm` Source: https://context7.com/proplot-dev/proplot/llms.txt Demonstrates the creation of custom color normalizers for colormap scaling. This includes diverging norms centered at a specific value, segmented norms defined by custom boundaries, and logarithmic norms. These normalizers control how data values are mapped to colors, allowing for specialized visualizations. ```python import proplot as pplt import numpy as np # Diverging norm centered at specific value norm = pplt.Norm('diverging', vcenter=0, vmin=-5, vmax=10) # Segmented norm with custom boundaries norm = pplt.Norm('segmented', levels=[0, 1, 3, 7, 15]) # Logarithmic norm norm = pplt.Norm('log', vmin=1, vmax=1000) # Use in plotting fig, axs = pplt.subplots(ncols=2, refwidth=2.5) state = np.random.RandomState(51423) data = 5 * (state.rand(20, 20) - 0.5).cumsum(axis=0) # Default linear norm m1 = axs[0].pcolormesh(data, cmap='CoolWarm') axs[0].format(title='Linear norm') # Diverging norm centered at zero m2 = axs[1].pcolormesh(data, cmap='CoolWarm', norm=norm) axs[1].format(title='Diverging norm') fig.colorbar(m1, loc='b', col=1, label='Linear') fig.colorbar(m2, loc='b', col=2, label='Diverging') ``` -------------------------------- ### Proplot Configuration: Omitting Dots in Setting Names Source: https://github.com/proplot-dev/proplot/blob/master/docs/configuration.rst Explains and demonstrates how to configure settings that contain dots (e.g., 'title.loc') by omitting the dots. This applies to both global and local configuration methods. ```python import proplot as pplt # Apply globally, omitting dots pplt.rc.titleloc = value pplt.rc.update(titleloc=value) # Apply locally, omitting dots fig, ax = pplt.subplots() ax.format(titleloc=value) ``` -------------------------------- ### Proplot Axes Contour and Gridbox Labeling Source: https://github.com/proplot-dev/proplot/blob/master/docs/why.rst Demonstrates how to draw contour and grid box labels on-the-fly using the 'labels' keyword in Proplot's contour, contourf, pcolormesh, and pcolor commands. Labels are automatically colored based on the background luminance. This functionality is part of the PlotAxes class. ```python import proplot as pplt fig, ax = pplt.subplots() # Example usage with contourf data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] cf = ax.contourf(data, labels=True) # Example usage with pcolormesh c = ax.pcolormesh(data, labels=True) fig.show() ``` -------------------------------- ### Control Super Label Padding with RCParams Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Adds new rcParams (`suptitle.pad`, `leftlabel.pad`, `toplabel.pad`, `bottomlabel.pad`, `rightlabel.pad`) to control padding for super labels, improving alignment. These can also be set locally via `ax.format`. ```Python # rcParams setting proplot.rc.update({'suptitle.pad': 10, 'leftlabel.pad': 5}) # Local setting ax.format(suptitlepad=12, leftlabelpad=6) ``` -------------------------------- ### Color Utility Functions Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces utility functions for color manipulation, including shifting hue and converting colors to HEX strings. The `to_hex` function ensures that color manipulation functions return HEX strings by default, preventing potential warnings. ```python from proplot.utils import shift_hue, to_hex # Shift hue of a color shifted_color = shift_hue('red', 0.2) # Convert to HEX string hex_color = to_hex('blue') print(hex_color) # Output: '#0000ff' ``` -------------------------------- ### Plotting with Named Data Keys Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Enables plotting commands to accept string keys for x and y data from a dataset, using `standardize_1d` and `standardize_2d`. This mirrors a feature present in Matplotlib's `plot`. ```python import proplot as p import pandas as pd fig, ax = p.subplots() data = pd.DataFrame({'col1': [1, 2, 3], 'col2': [4, 5, 6]}) # Plot using data keys ax.plot('col1', 'col2', data=data) ``` -------------------------------- ### Use Titlebbox and Abcblobbox for Inner Titles Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces `titlebbox` and `abcbbox` as alternatives to `titleborder` and `abcborder` for applying boxes around 'inner' titles and a-b-c labels. Borders are still the default. ```Python ax.set_title('My Title', titlebbox=True) ax.set_xlabel('X-axis', abcbbox=True) ``` -------------------------------- ### Proplot Colors and Colormap Warning Improvement Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Improves the warning message shown when users pass both `colors` and `cmap`, recommending the use of `edgecolor` to set edges. ```python # Example of conflicting arguments # ax.plot(..., colors=['r', 'g'], cmap='viridis') ``` -------------------------------- ### Proplot Geographic Plotting with Cartopy or Basemap Source: https://github.com/proplot-dev/proplot/blob/master/docs/why.rst Shows how to create geographic plots using either Cartopy or Basemap as backends in Proplot. Geographic axes are created by specifying a projection name, and features can be formatted using the GeoAxes.format command. The default backend is Cartopy, but Basemap can be selected. ```python import proplot as pplt # Using Cartopy backend (default) fig, ax = pplt.subplots(proj='mercator') # Example projection # Using Basemap backend # fig, ax = pplt.subplots(proj='mercator', backend='basemap') # Adding continents and formatting gridlines ax.format(continents=True, latlines=pplt.arange(-90, 91, 30), lonlines=pplt.arange(-180, 181, 60)) fig.show() ``` -------------------------------- ### Proplot Backend Pyplot Functions Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Adds commonly used backend-related pyplot functions to the top-level proplot namespace for easier access without direct pyplot import. This facilitates a more seamless workflow within ProPlot sessions. ```python import proplot # Now available directly from proplot proplot.ion() proplot.ioff() proplot.isinteractive() proplot.switch_backend('agg') ``` -------------------------------- ### Proplot Scaling Functions Opacity Fix Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Corrects an issue where channel-setting and scaling functions, such as `scale_luminance`, were dropping the opacity channel. ```python # Example usage of scale_luminance # ax.scale_luminance(..., opacity=0.5) # Opacity is now preserved ``` -------------------------------- ### Equal Spacing Options for Tight Layout Source: https://github.com/proplot-dev/proplot/blob/master/WHATSNEW.rst Introduces `wequal`, `hequal`, and `equal` options to force the tight layout algorithm to make subplot spacings equal, while still using automatic spacing. This provides finer control over subplot arrangement. ```python import proplot as p # Create a figure with equal spacing options fig, axes = p.subplots(nrows=2, ncols=2, wequal=True, hequal=True) # Or use 'equal' for both horizontal and vertical # fig, axes = p.subplots(nrows=2, ncols=2, equal=True) ```