This application provides a graphical user interface (GUI) for plotting data from .dat
files or from specified directories Users can choose from different plot styles and customize various settings such as axis limits, titles, and legend inclusion.
- Select plot type (2D, 3D, or directory input).
- Choose a plot style from available options.
- Input custom x and y axis limits.
- Set titles for axes and the plot.
- Option to include a legend in the plot.
To run this application, make sure you have Python installed on your machine. You will also need the tkinter
module, which comes with most Python installations.
-
Clone this repository or download the source code.
-
Ensure all required plot style modules (
plot_style_<name>.py
) are in the same directory as the main script. -
Navigate to the project directory in your terminal.
-
Run the application using the command:
python3 main.py
- To add a plot style create a new python file and define a function to take in the '.dat' files
- Once defined implement the desired plotting logic, if you want to use the text box in the GUI the plot function needs to have the folowing parameters
def plot(plot_type, dat_files, x_limits=None, y_limits=None, x_title='', y_title='', plot_title='', include_legend=False)
- For the GUI to auto populate with the new plot style use the folowing naming convention
plot_style_<name>.py
- Use the provided
test.py
and.dat
files as a guide (rename thetest.py
file toplot_style_sine.py
- Directory input only useful for scattering rate
- When GUI pops up there is no indication if user is selecting X or Y data
- No 3D graph support yet
This function scans the current directory for Python files that match the naming convention plot_style_<name>.py
. It extracts the style names by removing the prefix and file extension, returning a list of available plot styles.
Returns:
list
: A list of available plot style names (without theplot_style_
prefix and.py
extension).
This function is executed when the user clicks the "Plot" button in the GUI. It handles the following tasks:
- Plot Type Determination: It checks whether the user selected "Directory Input" or specified
.dat
files for plotting. - Directory/File Selection: If "Directory Input" is selected, it prompts the user to choose directories for real and complex scattering rate files. If
.dat
files are selected, it allows the user to choose the files to be plotted. - Input Validation: It verifies that directories or files were selected; if not, it displays an error message.
- Retrieve User Inputs: It collects user inputs for x and y limits, axis titles, plot title, and whether to include a legend.
- Dynamic Module Import: It imports the selected plot style module using
importlib
. - Plot Execution: It calls the
plot
function from the selected plot style module, passing the necessary parameters for plotting. - Error Handling: It manages potential errors, displaying error messages if the selected plot style is not found or if any other exception occurs.
Returns:
- None
- Initialization: The main GUI window is initialized with the title "Plotting GUI".
- Plot Type Selection: A dropdown menu allows users to select between different plot types (2D, 3D, or Directory Input).
- Plot Style Selection: Another dropdown menu lets users choose from available plot styles fetched by
get_plot_styles()
. - Axis Limit Inputs: Input fields are provided for users to specify x and y limits.
- Axis Title Inputs: Users can enter titles for the x and y axes and the overall plot.
- Legend Checkbox: A checkbox is available to include or exclude a legend in the plot.
- Plot Button: A button labeled "Plot" triggers the user to select the files or folders for the desired pot once selected it calls the
plot()
function. When selecting files the order matters, select the x-axis values then control+click the y values.