### Setting up Getdist for plotting Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html This example provides the basic setup required to use Getdist for plotting, including importing necessary modules and creating an MCSamples object. ```python import numpy as np import matplotlib.pyplot as plt import seaborn as sns from getdist import MCSamples from getdist.plots import GetDistPlotter, PlotSettings # Example: Create dummy data for an MCMC chain # Replace this with your actual chain loading mechanism num_samples = 1000 num_params = 3 # Generate random samples for demonstration samples_data = np.random.randn(num_samples, num_params) # Create an MCSamples object mcsamples = MCSamples(samples=samples_data, names=[f'param_{i}' for i in range(num_params)], labels=[f'Parameter {i}' for i in range(num_params)], ranges={f'param_{i}': [-5, 5] for i in range(num_params)}) # Initialize PlotSettings and update seaborn settings PlotSettings().update_sns_settings() # Initialize GetDistPlotter plotter = GetDistPlotter(mcsamples) print("Getdist setup complete. Plotter object created.") ``` -------------------------------- ### Minimal GetDist Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/README.md Load MCMC samples, get parameter statistics, and create a triangle plot. ```python import getdist # Load MCMC samples samples = getdist.loadMCSamples('chains/example') # Get parameter statistics mean = samples.mean('h') std = samples.std('h') print(f"h = {mean:.4f} ± {std:.4f}") # Create triangle plot from getdist.plots import GetDistPlotter plotter = GetDistPlotter(samples) plotter.triangle_plot() ``` -------------------------------- ### Install Optional Documentation Dependencies (uv) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install optional dependencies for documentation building using uv. ```bash uv pip install -e ".[docs]" ``` -------------------------------- ### Install All Dependencies (uv) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install all available dependencies, including development, GUI, Streamlit, and docs, using uv. ```bash uv pip install -e ".[dev,GUI,StreamlitGUI,docs]" ``` -------------------------------- ### Install Optional GUI Dependencies (uv) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install optional dependencies for GUI development using uv. ```bash uv pip install -e ".[GUI]" ``` -------------------------------- ### Install GetDist with Development Dependencies (uv) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install GetDist in editable mode with development dependencies using uv. ```bash uv pip install -e ".[dev]" ``` -------------------------------- ### Install GetDist using pip Source: https://github.com/cmbant/getdist/blob/master/README.rst Install the GetDist package using pip. This is the recommended method for most users. ```bash pip install getdist ``` -------------------------------- ### Plotting Quick Start Source: https://github.com/cmbant/getdist/blob/master/_autodocs/api-summary.md A quick guide to generating publication-quality plots, including triangle plots, using GetDist's plotting utilities. ```APIDOC ## Plotting Quick Start ### Description Provides a concise example of how to create common GetDist plots like triangle plots. ### Usage ```python from getdist import loadMCSamples from getdist.plots import GetDistPlotter, GetDistPlotSettings # Load samples samples = loadMCSamples('chains/example') # Configure plotting settings = GetDistPlotSettings(subplot_size_inch=2.5) settings.fontsize = 11 settings.colormap = 'viridis' # Create plotter plotter = GetDistPlotter(roots=samples, settings=settings) # Generate plots fig = plotter.triangle_plot( params=['h', 'omega_m', 'omega_b'], filled=True, legend_loc='upper right' ) # Save and show plotter.finish_plot() import matplotlib.pyplot as plt plt.savefig('triangle.pdf') plt.show() ``` ``` -------------------------------- ### Install GetDist from source Source: https://github.com/cmbant/getdist/blob/master/README.rst Install GetDist from local source files using pip. This is useful for development or when using a specific version. ```bash pip install -e /path/to/source/ ``` -------------------------------- ### Python Examples: makeList Utility Source: https://github.com/cmbant/getdist/blob/master/_autodocs/paramnames.md Demonstrates how to use the makeList function to ensure a parameter is in list format. ```python makeList("param") # ["param"] ``` ```python makeList(["a", "b"]) # ["a", "b"] ``` -------------------------------- ### Set up pre-commit hooks Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install pre-commit hooks to automatically run code quality checks before each commit. ```bash pre-commit install ``` -------------------------------- ### Install GetDist with Development Dependencies (pip) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install GetDist in editable mode with development dependencies using pip. ```bash pip install -e ".[dev]" ``` -------------------------------- ### Install Optional Streamlit GUI Dependencies (uv) Source: https://github.com/cmbant/getdist/blob/master/CONTRIBUTING.md Install optional dependencies for Streamlit GUI development using uv. ```bash uv pip install -e ".[StreamlitGUI]" ``` -------------------------------- ### Install PySide6 for GUI Application Source: https://github.com/cmbant/getdist/blob/master/docs/source/gui.md Install the PySide6 library, a dependency for running the traditional Qt-based GUI application from Python. This is necessary for the getdist-gui script to function. ```bash pip install PySide6 ``` -------------------------------- ### Plotting with Getdist Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Demonstrates basic plotting using the Getdist library. Requires Getdist to be installed and configured. ```python from getdist import plots, MCSamples import numpy as np # Create dummy samples mean = [0, 0] cov = [[1, 0.5], [0.5, 1]] num_samples = 10000 x = np.random.multivariate_normal(mean, cov, num_samples) samples = MCSamples(samples=x) # Create a plot object g = plots.get_single_plotter(width=6) # Plot the samples g.plot_1d_density(samples) g.fig.suptitle('1D Density Plot with Getdist') g.show() ``` -------------------------------- ### TextFile Write Method Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/types.md Demonstrates how to use the write method of the TextFile class to save its content to a specified file. ```python text = TextFile(['Line 1', 'Line 2', 'Line 3']) text.write('output.txt') ``` -------------------------------- ### Basic Plotting with Getdist Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Demonstrates the fundamental usage of Getdist for creating a simple plot. Ensure Getdist is installed and imported. ```python import getdist from getdist.plots import MCSamples import matplotlib.pyplot as plt # Assuming you have samples in a file named 'chain.txt' # samples = MCSamples('chain.txt') # For demonstration, let's create dummy samples from numpy import random samples = MCSamples(samples=[random.randn(100, 2)], names=['x', 'y'], ranges={'x': [-3, 3], 'y': [-3, 3]}) # Plotting the samples plt.figure() samples.plot_2d(0, 1) plt.show() ``` -------------------------------- ### Getdist Plotting Example Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html A basic example of using Getdist to create a plot. This snippet assumes you have Getdist installed and data in a compatible format. ```python from getdist import plots, MCSamples import numpy as np # Create dummy samples (replace with your actual data) samples = np.random.randn(1000, 3) param_names = ['param1', 'param2', 'param3'] mcsamples = MCSamples(samples=samples, names=param_names) # Create a plot (e.g., triangle plot) g = plots.get_single_plotter(width=8) g.triangle_plot([mcsamples], filled=True) plt.suptitle('Getdist Triangle Plot Example', y=1.02) plt.show() ``` -------------------------------- ### IniFile Example Usage Source: https://github.com/cmbant/getdist/blob/master/_autodocs/inifile.md Demonstrates loading configuration from a file, accessing parameters as different types with defaults, creating an IniFile from a dictionary, saving to a file, and iterating over parameters. ```python from getdist import IniFile # Load from file config = IniFile('analysis_settings.ini') # Access parameters num_bins = config.int('num_bins', default=40) accuracy = config.float('accuracy', default=0.0001) label = config.string('label', default='Sample') use_cache = config.bool('use_cache', default=True) # Create from dictionary config = IniFile({ 'param1': '10', 'param2': '3.14', 'param3': 'value' }) # Save to file config.saveFile('output.ini') # Iterate over parameters for key, value in config.params.items(): print(f"{key} = {value}") ``` -------------------------------- ### Install Streamlit for Web Interface Source: https://github.com/cmbant/getdist/blob/master/docs/source/gui.md Install the Streamlit library, which is required to run the Streamlit-based web interface for GetDist. This command installs Streamlit using pip. ```bash pip install streamlit ``` -------------------------------- ### Complete 1D Density Analysis Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/densities.md Demonstrates a full workflow for creating and analyzing a 1D Kernel Density Estimate (KDE). Includes sample generation, bandwidth estimation, KDE creation, contour level calculation, and density evaluation. ```python from getdist.densities import Density1D import numpy as np # Create from samples using KDE from getdist.kde_bandwidth import auto_bandwidth_1d samples = np.random.randn(10000) x = np.linspace(-4, 4, 200) # Estimate KDE bandwidth h = auto_bandwidth_1d(samples) # Create kernel density estimate # Note: Kernel1D and convolve1D are assumed to be imported or defined elsewhere # from getdist.convolve import Kernel1D, convolve1D # kernel = Kernel1D(winw=int(np.ceil(4*h)), h=h) # P = convolve1D(x, samples, kernel) # Create density object # density = Density1D(x, P) # Get 68% and 95% contour levels # levels = density.getContourLevels((0.68, 0.95)) # Evaluate at point # prob = density(1.5) ``` -------------------------------- ### Check PySide6 Installation Source: https://github.com/cmbant/getdist/blob/master/_autodocs/command-line.md Verify if PySide6 is installed and check its version. This is often a prerequisite for the GetDist GUI. ```bash # Check PySide6 installation python -c "import PySide6; print(PySide6.__version__)" # If missing: pip install PySide6 # Try GUI getdist-gui ``` -------------------------------- ### MCSamples Initialization and Usage Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/mcsamples.md Demonstrates how to load MCSamples from files or create them from NumPy arrays, and how to access basic parameter statistics like mean and standard deviation. ```python import getdist # Load from files samples = getdist.loadMCSamples('chains/example') # Create from arrays samples = getdist.MCSamples( samples=np.random.randn(1000, 3), weights=np.ones(1000), names=['param1', 'param2', 'param3'], labels=['p_1', 'p_2', 'p_3'] ) # Access parameter statistics mean = samples.mean('param1') std = samples.std('param1') ``` -------------------------------- ### Batch Processing Shell Script Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/MANIFEST.txt Example of a shell script for batch processing using GetDist. ```bash #!/bin/bash # Example batch processing script # ... (script logic for chain file management and output generation) ``` -------------------------------- ### Complete Plotting Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/plots.md Demonstrates loading samples, creating a GetDistPlotter with custom settings, generating a triangle plot, and displaying the figure. ```python from getdist import loadMCSamples from getdist.plots import GetDistPlotter, GetDistPlotSettings # Load samples samples = loadMCSamples('chains/example') # Create custom settings settings = GetDistPlotSettings(subplot_size_inch=2.5) settings.fontsize = 11 settings.linewidth = 1.2 # Create plotter plotter = GetDistPlotter(roots=samples, settings=settings) # Plot triangle diagram fig = plotter.triangle_plot( params=['h', 'omega_m', 'omega_b'], filled=True, legend_loc='upper right' ) # Finalize and show plotter.finish_plot() import matplotlib.pyplot as plt plt.show() ``` -------------------------------- ### Check Streamlit Installation Source: https://github.com/cmbant/getdist/blob/master/_autodocs/command-line.md Verify if Streamlit is installed and check its version. This is necessary for running the Streamlit web interface. ```bash # Check Streamlit installation python -c "import streamlit; print(streamlit.__version__)" # If missing: pip install streamlit # Clear cache rm -rf ~/.streamlit/ # Try web interface getdist-gui-stream ``` -------------------------------- ### ParamNames Constructor Examples Source: https://github.com/cmbant/getdist/blob/master/_autodocs/paramnames.md Demonstrates various ways to initialize a ParamNames object: loading from a file, auto-generating default names, and providing explicit lists of names and labels. ```python # From file params = ParamNames(fileName='chains/example.paramnames') # Auto-generate defaults params = ParamNames(default=3) # Creates: param1, param2, param3 with labels p_{1}, p_{2}, p_{3} # From lists params = ParamNames( names=['h', 'omega_m', 'omega_b'], labels=['h', '\Omega_m', '\Omega_b'] ) # Access parameters first = params.names[0] label = first.getLabel() ``` -------------------------------- ### Complete Analysis Pipeline Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/INDEX.md This Python script demonstrates a typical GetDist workflow: loading samples, checking convergence, calculating basic statistics, generating a triangle plot, and exporting contour levels. ```python import getdist from getdist.plots import GetDistPlotter # 1. Load samples samples = getdist.loadMCSamples('chains/example') # 2. Check convergence print(f"Correlation length: {samples.corr_length()}") # 3. Get constraints for param in ['h', 'omega_m', 'omega_b']: mean = samples.mean(param) std = samples.std(param) print(f"{param} = {mean:.4f} ± {std:.4f}") # 4. Create plots plotter = GetDistPlotter(samples) plotter.triangle_plot() # 5. Export constraints samples.getContourLevels(['h', 'omega_m']) ``` -------------------------------- ### Find Chain File Root Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/chains.md Example of using findChainFileRoot to locate chain files in a directory tree. ```python path = findChainFileRoot('/chains', 'experiment1/output') # Returns: '/chains/experiment1/output' if chain files exist there ``` -------------------------------- ### Work with Configuration Source: https://github.com/cmbant/getdist/blob/master/_autodocs/README.md Retrieve the global configuration object and access string settings with a default value. ```python config = getdist.get_config() setting = config.string('key', default='value') ``` -------------------------------- ### ParamInfo setFromString Examples Source: https://github.com/cmbant/getdist/blob/master/_autodocs/paramnames.md Demonstrates parsing parameter information from strings, including standard parameters with names, labels, and comments, and derived parameters marked with an asterisk. ```python param = ParamInfo() param.setFromString("omega_b \\Omega_b #Baryon density") # name='omega_b', label='\\Omega_b', isDerived=False, comment='Baryon density' # Derived parameter marked with * param.setFromString("age* Age_{\\rm Gyr} #Universe age") # isDerived=True ``` -------------------------------- ### Plotting chains with Getdist Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html This example shows how to plot the raw chains for each parameter. This is useful for diagnosing convergence issues and understanding the sampling process. ```python from getdist import MCSamples, plots import matplotlib.pyplot as plt # Load your samples (replace with your actual file path) samples = MCSamples(samples='path/to/your/chains.txt', names=['a', 'b', 'c'], labels=['\alpha', '\beta', '\gamma'], ranges={'a': [-2, 2], 'b': [-3, 3], 'c': [-4, 4]}) # Create a Plotter object plt.figure(figsize=(10, 6)) g = plots.get_single_plotter(chain_plotting_kwargs={'over_plot': 'mean', 'num_thin_thin': 10}) # Plot chains for parameter 'a' g.plot_chain(samples, 'a') plt.show() ``` -------------------------------- ### Getdist Plotting Example Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Demonstrates a basic plotting example using Getdist, likely for visualizing posterior distributions or confidence contours. ```python from getdist import plots, MCSamples import numpy as np # Assuming 'samples' is an MCSamples object # For demonstration, let's create a dummy one num_params = 3 num_samples = 1000 np.random.seed(42) means = [0, 0, 0] cov = np.eye(num_params) samples_data = np.random.multivariate_normal(means, cov, num_samples) param_names = ["param1", "param2", "param3"] mcsamples = MCSamples(samples=samples_data, names=param_names) plt.figure() g = plots.get_single_plotter(width=8) g.plot_1d_prior(mcsamples, "param1") plt.show() ``` -------------------------------- ### Find Chain Files Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/chains.md Demonstrates how to use chainFiles to find chain files with different separators and index specifications. ```python # Find all chain files with underscore separator files = chainFiles('chains/example') # matches: example.txt, example_1.txt, example_2.txt # Find specific chains files = chainFiles('chains/example', chain_indices=[0, 1, 2]) # Exclude certain chains files = chainFiles('chains/example', chain_exclude=[5, 6]) # Use dot separator for Cobaya format files = chainFiles('chains/example', separator='.') ``` -------------------------------- ### numberFigs Examples Source: https://github.com/cmbant/getdist/blob/master/_autodocs/types.md Provides examples of using numberFigs to format numbers to specific significant figures, including cases with leading zeros and scientific notation. ```python numberFigs(1.234567, 4) # '1.235' numberFigs(0.001234, 2) # '0.0012' numberFigs(1234, 2) # '1200' numberFigs(0.00456, 2, sci=True) # ('4.6', -3) ``` -------------------------------- ### Accessing GetDist Configuration at Runtime Source: https://github.com/cmbant/getdist/blob/master/_autodocs/inifile.md Demonstrates how to import the getdist library and retrieve configuration settings using the get_config() method. Shows accessing string values with optional defaults. ```python import getdist # Get configuration object config = getdist.get_config() # Access settings cache = config.string('cache_dir') output = config.string('output_base_dir', default='.') ``` -------------------------------- ### Setup and Version Check Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.ipynb Initializes the plotting environment for inline display and imports necessary GetDist modules. It also prints the versions of GetDist and Matplotlib being used. ```python # Show plots inline, and load main getdist plot module and samples class %matplotlib inline %config InlineBackend.figure_format = 'retina' import os import sys sys.path.insert(0, os.path.realpath(os.path.join(os.getcwd(), ".."))) import getdist import IPython import matplotlib import matplotlib.pyplot as plt from getdist import MCSamples, plots print("GetDist Version: %s, Matplotlib version: %s" % (getdist.__version__, matplotlib.__version__)) ``` -------------------------------- ### 1D and 2D Plotting Example Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html A combined example showing both 1D marginalized posterior distributions and 2D contour plots. This provides a comprehensive overview of parameter posteriors. ```python import getdist from getdist import MCSamples # Load samples (replace with your actual sample loading) # samples = MCSamples(samples=np.random.rand(100, 3), names=['a', 'b', 'c'], # labels=['alpha', 'beta', 'gamma']) # Example with dummy data if no samples are loaded samples = MCSamples(samples=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]], names=['a', 'b', 'c'], labels=['alpha', 'beta', 'gamma']) # Create a combined plot # g = getdist.plots.get_chain_plotter(rows=2, cols=2, width=8, dpi=150) # g.plot_chain(samples, ['a', 'b', 'c']) # g.export("combined_1d_2d_plot.png") # Placeholder for actual plotting code print("Combined 1D and 2D plotting code would go here.") ``` -------------------------------- ### Cobaya Parameter Metadata Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/cobaya_interface.md Example of parameter metadata structure within a Cobaya info dictionary, specifying priors, LaTeX labels, and derived status. ```yaml params: h: prior: {min: 0.5, max: 0.9} latex: h drop: False omega_m: prior: {min: 0.1, max: 0.9} latex: \Omega_m age: latex: Age derived: True # Derived parameter ``` -------------------------------- ### texEscapeText Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/types.md Demonstrates the usage of texEscapeText to escape an underscore in a parameter name for LaTeX. ```python texEscapeText("parameter_name") # "parameter\textunderscore name" ``` -------------------------------- ### Instantiate Core GetDist Classes Source: https://github.com/cmbant/getdist/blob/master/_autodocs/INDEX.md Demonstrates how to instantiate the main exported classes at the top level of the getdist library, including MCSamples, ParamNames, and IniFile. ```python samples = getdist.MCSamples(...) params = getdist.ParamNames(...) ini = getdist.IniFile('config.ini') ``` -------------------------------- ### Ranges File Format Source: https://github.com/cmbant/getdist/blob/master/_autodocs/README.md Example format for a ranges file, specifying the bounds for each parameter. ```text 0.5 0.9 # h 0.01 0.3 # omega_b ``` -------------------------------- ### Paramnames File Format Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/paramnames.md Illustrates the plain text format for .paramnames files, specifying parameter names, labels, and comments. ```text name [label] [# comment] h h omega_b \Omega_b # Baryon density omega_c \Omega_c # Cold dark matter omega_l \Omega_\Lambda # Dark energy age* \text{Age} # Derived: universe age in Gyr ``` -------------------------------- ### Histogram Example Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Displays a histogram to visualize the distribution of a dataset. Adjust the number of bins as needed. ```python import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=30, color='skyblue', edgecolor='black') plt.xlabel('Value') plt.ylabel('Frequency') plt.title('Histogram of Random Data') plt.show() ``` -------------------------------- ### Basic Plotting with Getdist Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Demonstrates how to create a basic plot of cosmological parameters from a chain file. Requires the 'getdist' library to be installed. ```python from getdist import plots import matplotlib.pyplot as plt # Load chains # Assumes you have chain files in a directory named 'chains' # and a roots.ini file in the same directory. # Example: roots = ['mychain1', 'mychain2'] # Example: chains_dir = 'chains' # For demonstration, let's assume roots and chains_dir are defined # Replace with your actual chain names and directory roots = ['example_chain'] chains_dir = '.' # Create a Plotter object g = plots.get_single_plotter(chain_dir=chains_dir, filename='root.ini', normalized=True) # Add chains to the plotter g.add_chains(roots) # Set parameters to plot (optional, defaults to all parameters) # g.settings.axes_labels = ['\Omega_M', '\Omega_\Lambda', 'w'] # Create the plot g.plot_1d() # For 1D marginalized posteriors # g.plot_2d() # For 2D contours # Show the plot plt.show() ``` -------------------------------- ### Typical Exception Handling Source: https://github.com/cmbant/getdist/blob/master/_autodocs/README.md Demonstrates how to handle potential errors during sample loading and analysis using try-except blocks. ```python try: samples = getdist.loadMCSamples('chains/example') except OSError as e: print(f"Chain files not found: {e}") except getdist.mcsamples.MCSamplesError as e: print(f"Analysis error: {e}") ``` -------------------------------- ### Plotting a Single 1D Histogram Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Basic example of plotting a single 1D histogram for a parameter. ```python from getdist import MCSamples, plots samples = MCSamples("path/to/chain", names=['a', 'b']) g = plots.get_single_plotter() g.plot_1d(samples, 'a') ``` -------------------------------- ### times_ten_power Example Source: https://github.com/cmbant/getdist/blob/master/_autodocs/types.md Shows how to use times_ten_power to create a LaTeX string for 10 to the power of 3. ```python times_ten_power(3) # Returns: r"\cdot 10^{3}" ``` -------------------------------- ### Read and Access Configuration from IniFile Source: https://github.com/cmbant/getdist/blob/master/_autodocs/INDEX.md Demonstrates reading a configuration file using IniFile and accessing various settings like integers, strings, and booleans, with support for default values. ```python from getdist import IniFile config = IniFile('analysis.ini') num_bins = config.int('num_bins', default=40) label = config.string('label') cache = config.bool('use_cache', default=True) ``` -------------------------------- ### Plotting with Getdist and Matplotlib Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Illustrates how to integrate Getdist plotting with Matplotlib for more customization. Requires Matplotlib to be installed. ```python import matplotlib.pyplot as plt from getdist.plots import MCSamples from getdist import plots # Assume 'samples' is a loaded MCSamples object # samples = MCSamples("path/to/your/chain.txt") # Create a plotter instance plt_obj = plots.get_single_plotter(width=7) # Plot a 1D density plt_obj.plot_1d_density(samples, param_names=['omega_m']) # Get the current matplotlib axes and customize ax = plt.gca() ax.set_title("Customized 1D Density Plot") ax.set_xlabel("Omega_m") plt.show() # Create a new figure for a 2D plot plt_obj.figure(figsize=(7, 7)) plt_obj.plot_2d_density(samples, param_names=['omega_m', 'w0']) # Get the current matplotlib axes and customize ax = plt.gca() ax.set_ylabel("w0") plt.show() ``` -------------------------------- ### Heatmap Example Source: https://github.com/cmbant/getdist/blob/master/docs/plot_gallery.html Displays a matrix of values as a color-encoded grid. Useful for correlation matrices or image data. ```python import matplotlib.pyplot as plt import numpy as np data = np.random.rand(10, 10) plt.imshow(data, cmap='hot', interpolation='nearest') plt.colorbar() plt.title('Heatmap Example') plt.show() ```