2D Figure Generation Details ============================= The ``make_figure.py`` script is a command-line tool for automatically generating publication-quality figures from CSV files generated by LNB-MDT analysis modules. Overview -------- This tool automatically: - Detects the data type from your CSV file - Determines available plot types (line, bar, scatter, heatmap) - Generates high-resolution figures (300 DPI) suitable for publications Prerequisites ------------- - Python 3.x with required packages (matplotlib, pandas, seaborn) - CSV files generated by LNB-MDT analysis modules Basic Usage ----------- Simple Command ~~~~~~~~~~~~~~ .. code-block:: bash LNB-MDT FIGURE -f -o **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/area_results.csv -o cases_lnb/area_plot.png Interactive Mode (Default) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ When you don't specify ``--plot-type``, the tool will display an interactive menu: .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/height_results.csv -o cases_lnb/height_plot.png **Output:** .. code-block:: text Reading file: cases_lnb/height_results.csv Data description: Height (nm) Data shape: (150, 25) Time unit: ns Available plot types: 1. Line Chart 2. Bar Chart 3. Scatter Chart 4. Generate All Please select plot type (1-4): Non-Interactive Mode ~~~~~~~~~~~~~~~~~~~~ Use ``--no-interactive`` flag to skip the menu and use the default plot type: .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/area_results.csv -o cases_lnb/area_plot.png --no-interactive Specify Plot Type ~~~~~~~~~~~~~~~~~ Directly specify the plot type: .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/cluster_results.csv -o cases_lnb/cluster_plot.png --plot-type line Command-Line Options ------------------- .. list-table:: Command-Line Options :header-rows: 1 :widths: 15 10 50 10 * - Option - Short - Description - Required * - ``--file`` - ``-f`` - Input CSV file path - Yes * - ``--output`` - ``-o`` - Output image file path - Yes * - ``--plot-type`` - - Plot type: ``line``, ``bar``, ``scatter``, ``heatmap``, or ``all`` - No * - ``--no-interactive`` - - Non-interactive mode (use default if plot-type not specified) - No Supported Plot Types ------------------- The tool automatically detects available plot types based on your CSV file content: Line Chart (``line``) ~~~~~~~~~~~~~~~~~~~~~~ - **Supported for**: All data types - **Use case**: Time series data, trends over time - **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/area_results.csv -o cases_lnb/area_line.png --plot-type line Bar Chart (``bar``) ~~~~~~~~~~~~~~~~~~~ - **Supported for**: LipidsFigure, BubbleFigure, DensityTime - **Use case**: Comparing values across different categories - **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/anisotropy_results.csv -o cases_lnb/anisotropy_bar.png --plot-type bar Scatter Chart (``scatter``) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Supported for**: LipidsFigure only - **Use case**: Relationship between variables, distribution analysis - **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/sz_results.csv -o cases_lnb/sz_scatter.png --plot-type scatter Heatmap (``heatmap``) ~~~~~~~~~~~~~~~~~~~~~~ - **Supported for**: DensityFigure (Radius method) only - **Use case**: Multi-dimensional density data visualization - **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/density_radius_results.csv -o cases_lnb/density_heatmap.png --plot-type heatmap Generate All (``all``) ~~~~~~~~~~~~~~~~~~~~~ - **Supported for**: All data types - **Use case**: Generate all available plot types at once - **Example:** .. code-block:: bash LNB-MDT FIGURE -f cases_lnb/area_results.csv -o cases_lnb/area_plots --plot-type all When using ``all``, the tool will generate multiple files with suffixes: - ``area_plots_line.png`` - ``area_plots_bar.png`` - ``area_plots_scatter.png`` (if supported) Data Type Detection ------------------- The tool automatically detects the data type from your CSV file: LipidsFigure (Type 0) ~~~~~~~~~~~~~~~~~~~~~ - **Detected by**: Contains ``Resname`` column - **Supported plots**: Line, Bar, Scatter - **Examples**: Area, Height, Sz Order Parameter, Mean Curvature BubbleFigure (Type 1) ~~~~~~~~~~~~~~~~~~~~~ - **Detected by**: No ``Resname`` column, bubble-related data - **Supported plots**: Line, Bar - **Examples**: Anisotropy, Gyration, Cluster, Density (single radius) DensityFigure (Type 3) ~~~~~~~~~~~~~~~~~~~~~~~ - **Detected by**: Description contains "DensityTime", "Density Radius", "Multi-Radius Density", etc. - **Supported plots**: - DensityTime: Line, Bar - DensityRadius: Line, Heatmap - **Examples**: DensityTime, DensityRadius, Multi-Radius Density Analysis Examples -------- Example 1: Generate Line Chart for Area Analysis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash LNB-MDT FIGURE \ -f cases_lnb/area_results.csv \ -o cases_lnb/area_line.png \ --plot-type line Example 2: Generate All Plot Types for Height Analysis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash LNB-MDT FIGURE \ -f cases_lnb/height_results.csv \ -o cases_lnb/height_plots \ --plot-type all This will generate: - ``height_plots_line.png`` - ``height_plots_bar.png`` - ``height_plots_scatter.png`` Example 3: Generate Heatmap for Density Analysis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash LNB-MDT FIGURE \ -f cases_lnb/density_radius_results.csv \ -o cases_lnb/density_heatmap.png \ --plot-type heatmap Example 4: Batch Processing (Non-Interactive) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash # Generate figures for multiple analysis results for csv_file in cases_lnb/*_results.csv; do base_name=$(basename "$csv_file" _results.csv) LNB-MDT FIGURE \ -f "$csv_file" \ -o "cases_lnb/figures/${base_name}_plot.png" \ --plot-type line \ --no-interactive done Example 5: Generate All Available Types Interactively ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash LNB-MDT FIGURE \ -f cases_lnb/cluster_results.csv \ -o cases_lnb/cluster_plot.png The tool will show available options and let you choose. Output Files ------------ - **Format**: PNG images - **Resolution**: 300 DPI (publication quality) - **Size**: Automatically optimized with ``bbox_inches='tight'`` - **Naming**: - Single plot: Uses the specified output path - Multiple plots (``all``): Adds suffix ``_.png`` CSV File Format --------------- The tool expects CSV files generated by LNB-MDT analysis modules with the following structure: Standard Format ~~~~~~~~~~~~~~~ .. code-block:: csv Description,Frame,Time(ns),Resname,0.0,1.0,2.0,... Area(nm^2),0,0.0,DPPC,0.65,0.67,0.69,... Area(nm^2),1,0.0,DAPC,0.72,0.74,0.71,... Key Columns ~~~~~~~~~~~ - **Description**: Analysis type (e.g., "Area(nm^2)", "Height (nm)") - **Frame**: Frame number - **Time(ns)**: Simulation time in nanoseconds - **Resname**: Residue name (for LipidsFigure) - **Numeric columns**: Time points or other dimensions Supported Analysis Types ------------------------ The tool supports figures for all LNB-MDT analysis modules: .. list-table:: Supported Analysis Types :header-rows: 1 :widths: 25 30 45 * - Analysis Module - CSV File - Supported Plot Types * - Area - ``area_results.csv`` - Line, Bar, Scatter * - Height - ``height_results.csv`` - Line, Bar, Scatter * - Cluster - ``cluster_results.csv`` - Line, Bar * - Anisotropy - ``anisotropy_results.csv`` - Line, Bar * - Gyration - ``gyration_results.csv`` - Line, Bar * - Sz Order Parameter - ``sz_results.csv`` - Line, Bar, Scatter * - Density (Time) - ``density_time_results.csv`` - Line, Bar * - Density (Radius) - ``density_radius_results.csv`` - Line, Heatmap Integration with Analysis Workflow ----------------------------------- Typical workflow: .. code-block:: bash # 1. Run analysis LNB-MDT AREA \ -g cases_lnb/lnb.gro \ -x cases_lnb/lnb.xtc \ -o cases_lnb/area_results.csv \ -r "{'DPPC': ['PO4'], 'DAPC': ['PO4'], 'CHOL': ['ROH']}" # 2. Generate figure LNB-MDT FIGURE \ -f cases_lnb/area_results.csv \ -o cases_lnb/area_plot.png \ --plot-type line Troubleshooting --------------- Error: "Input file does not exist" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: Check the file path. Use relative paths from the project root directory. Error: "Failed to read CSV file" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: Ensure the CSV file is properly formatted and generated by LNB-MDT analysis modules. Error: "Unable to determine available plot types" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: The CSV file may not match expected formats. Check that it was generated by an LNB-MDT analysis module. Error: "Plot type 'X' is not available" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: The specified plot type is not supported for this data type. Use ``--plot-type all`` to see available options. Warning: "Plot type 'X' is not supported, skipping" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: This is normal when using ``--plot-type all``. The tool will skip unsupported plot types and generate the rest. Figures not displaying correctly ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - **Solution**: Ensure matplotlib backend is set correctly. The tool uses 'Agg' backend for non-interactive mode. Tips ---- 1. **Use ``--plot-type all``** to see all available visualization options for your data 2. **Check output directory** exists before running (or the tool will create it) 3. **Use descriptive output names** to easily identify generated figures 4. **Batch processing**: Combine with shell scripts for processing multiple CSV files 5. **Publication quality**: All figures are generated at 300 DPI by default Notes ----- - The tool automatically detects the appropriate figure class (LipidsFigure, BubbleFigure, or DensityFigure) based on CSV content - Output images are saved in PNG format with 300 DPI resolution - The tool uses non-interactive matplotlib backend ('Agg') to avoid GUI dependencies - All paths are relative to the project root directory