Skip to content

Eben60/CasualPlots.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

124 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CasualPlots

Build Status

Aims

CasualPlots.jl aims to provide a graphical user interface (GUI) to simplify the creation of plots in Julia. The tool is positioned in the middle ground between purely script-based plotting and standalone GUI plotting applications.

The tool is intended to be started from a Julia command line, providing access to the variables defined in the script's environment.

The expected user is someone who wants an easy way to create common plot types without memorizing dozens or hundreds of options.

What It Does

CasualPlots provides a GUI window where you can quickly visualize your data. You can select data from your Main namespace, or from disk, and the plot will be displayed along with a table view of your data. You can customize some common attributes like plot title, and switch between different plot types. You can simply save it as a PNG, SVG, or PDF file directly from the GUI, or you can manually customize the exported Makie.Figure object.

How It Does It

It uses Bonito.jl, AlgebraOfGraphics.jl, and WGLMakie.jl under the hood.

How To Use

Installation

Note: it needs Julia v1.10 or higher. The package is registered. Keep in mind, the package has a heavy dependency footprint (pulling in around 300 transitive dependencies), so, to avoid potential version conflicts, you might want to avoid installing it into your "main/default" environment like this:

(@v1.12) pkg> add CasualPlots

Instead better install it in directly your project environment(s). Alternatively you can install it into a shared environment and make it available from everywhere with the help of ShareAdd.jl package:

julia> using ShareAdd

julia> @usingany CasualPlots

@usingany would import a package from any shared environment if available, otherwise first install it into a shared env of your choice.

Accessing GUI

The package creates a Bonito GUI app, which can be opened in an Electron.jl window, in a browser, or in a plot pane of VSCode.

Default display, which may be plot pane or browser

julia> using CasualPlots

julia> using CSV, XLSX # optionally

julia> app = casualplots_app()

julia> display(app)

julia> close(app) # you may close the app when you no longer need it

Serving to browser

julia> app = casualplots_app()

julia> server = Bonito.Server(app, "127.0.0.1", 8000)
┌ Warning: Port in use, using different port. New port: 8001
└ @ Bonito.HTTPServer ~/.julia/packages/Bonito/18mTs/src/HTTPServer/implementation.jl:346
Server:
  isrunning: true
  listen_url: http://localhost:8001
  online_url: http://localhost:8001
  http routes: 1
    / => App
  websocket routes: 0

After starting the server, go to browser and navigate to http://localhost:8000 or http://127.0.0.1:8000. You get a message in the Terminal if the port 8000 is busy and other port is used.

Opening a Standalone Electron Window

julia> app = casualplots_app()

julia> Ele.serve_app(app)

The author sees Electron as the preferred usage way.

See usage/testing examples in the scripts in the folder src/scripts of the package.

Accessing Data and Plotting

Note: Even on a fast computer, there may be a noticeable "Time To First Plot" delay. Please be patient on the first use.

Existing Variables

Variables (Vector, Matrix, DataFrame) in Main are automatically detected. For DataFrames, the "wide" format is expected.

In the Source tab:

  • For X, Y Arrays source, first, select an X variable. Only 1D arrays (vectors) of numeric or Unitful values are shown.
    • The Y dropdown then shows variables whose first dimension matches X's length. Click (Re-)Plot to create plot.
  • For File/DataFrame, select one from the dropdown, then pick your columns. The first selected column becomes the X-values. Click (Re-)Plot.
  • You can select data range.

The selected data is also displayed in the table view.

From Disk

Supported formats are CSV and XLSX (Excel). These features use package extensions, so you must import the CSV and/or XLSX packages separately.

The GUI provides just a small subset of the file reading options available in the respective packages. If you have a file with some fancy formatting, you might need to load it into a DataFrame manually in the REPL; the data will then be available as a standard variable.

In the Open tab:

  • Optionally configure reading options (header row, delimiter, decimal separator, etc.).
  • Click Open File to select your file.
    • CSV files are read immediately.
    • For Excel files, select a sheet from the dropdown and click Reload.
  • The data is displayed in the table. You can adjust options and click Reload to read the data anew.
  • Once loaded, the data is available under "opened file" in the Source tab's File/DataFrame dropdown.

Plot Formatting Options

WIP, see Format tab.

Accessing Created Plot

The plot (the Makie.Figure object, to be exact) is exported as cp_figure, whereas its Axis object exported as cp_figure_ax. Both objects will be accessible in REPL as soon as the plot is displayed. You are free to modify them in any way possible in Makie:

# the change will be immediately reflected in the currently displayed plot
julia> hidespines!(cp_figure_ax, :r, :t)

Current State

In short, it is WIP, however, the main goals are already implemented and the package is usable. As the next step, it is planned to implement more plot formatting options.

  • [✅] A GUI with panes for user interactions, plot display, and source data display.
  • [✅] Data sources: variables defined in the Main module (vectors, matrices, dataframes).
    • [✅] Range selection, DataFrame columns selection.
  • [✅] Data sources: CSV and XLSX files.
    • [✅] Support for CSV/XLSX file reading options (kwargs).
  • [✅] Plotting: Lines and Scatter plots.
    • [🚧] More plot formatting options being added.
  • [✅] Saving plot to a file.
  • [✅] Exporting the Figure object.
  • [✅] Precompile to reduce TTFP.
  • [❌] Documenter.jl based documentation.
  • [❌] Automatic generation of Julia code corresponding to the user’s actions.
  • [❌] Applying a least-squares fit from the GUI.

Screenshots

About

CasualPlots.jl aims to provide a graphical user interface (GUI) to simplify the creation of plots in Julia. The tool is positioned in the middle ground between purely script-based plotting and standalone GUI plotting applications.

Topics

Resources

License

Stars

Watchers

Forks

Contributors