Git Product home page Git Product logo

smoothliveplot.jl's Introduction

SmoothLivePlot.jl

SmoothLivePlot.jl is a Julia package for creating live-style plots during calculations.

Motivation

Updating the Juno plot plane during calculations creates new plots on top of the old ones. This produces a flickering effect e.g.:

To smoothly update of plots, I generalised a solution found by user ckneale. It uses Observables.jl and WebIO.jl so that the plot can listen to changes in its elements.

Currently, I have tested the following capabilities:

  • Modifying values in X and/or Y array(s) in scatter and plot
  • Modifying colours in scatter and plot
  • Modifying text elements (e.g. titles, xlabels, etc...)
  • Modifying matricies in contour plots
  • Adding new elements to X,Y arrays in 2d line and scatter plots
  • Adding new elements to X,Y,Z in 3d line and scatter plots

Note: this package is designed to work with the plot plane in Juno. If you force it to plot in a gui it will look really weird.

Using the package

  1. Import the module using using SmoothLivePlot.
  2. Create a live plot with macro outPlotObject = @makeLivePlot myPlotFunction(argument1, argument2, ...).
    • Function myPlotFunction(argument1, argument2, ...) is a user defined plotting function.
    • Output outPlotObject is a mutable output array of plot features. Its elements are the input aruments of myPlotFunction().
  3. Modify plot elements with function modifyPlotObject!(outPlotObject, arg2 = newArg2, arg1 = newArg1, ...).
    • The first argment of modifyPlotObject!() must be the mutable output array.
    • The following argments are optional and named. The name/value pair must be arg<x> = newArg1, where <x> in the name is an integer that indicates the position of the argument in the original plotting function myPlotFunction().
    • E.g. to modify argument2 to newArgument2, use modifyPlotObject!(outPlotObject, arg2 = newArgument2).
    • The modified arguments do not have to be in any specific order, and are updated at the same time.

Short example

Here's a video showing an output live-plot from some magnetohydrodynamic calculations:

exampleSmoothPlot

TODOs

  • Add capability to add additional elements to plots.
  • Benchmark performance.

Changelog

  • Version 0.1.0 - Introduced original version.

smoothliveplot.jl's People

Contributors

williamjsdavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

shg

smoothliveplot.jl's Issues

Test set opens in gui instead of plot plane

For some reason, in recent tests the smooth plots open in a gui instead of the Juno plot plane window. Functionality of the smooth plotting is still active, but the destination is wrong. This may be a julia-client issue.

Plot line disappears if any element is set too large

If any ordinate element in a plot array is either initially set (or modified to) a value that is too large, the plot line vanishes.

To reproduce the bug:

using Plots, SmoothLivePlot

function myPlotFun(yVals)
   plot(0:0.1:1, 0:0.1:1)
   plot!(range(0,1,length=length(yVals)), yVals)
   ylims!(0,2)
end

inyVals = collect(0.2:0.01:0.3)

outPltOb = @makeLivePlot myPlotFun(inyVals)

Screen Shot 2020-04-09 at 12 38 30

Modifying an ordinate element of the plot object to modest values produces no error:

newYvals = copy(inyVals)
newYvals[5] = 10

modifyPlotObject!(outPltOb, arg1 = newYvals)

Screen Shot 2020-04-09 at 12 38 49

However, modifying to large values makes the line disappear

newYvals[5] = 1e8

modifyPlotObject!(outPltOb, arg1 = newYvals)

Screen Shot 2020-04-09 at 12 38 58

"Large" ordinate values that cause the bug seem to be >1e8. Interestingly, this bug does not occur for large negative numbers. This bug does not occur with scatter. Large abscissa have not been tested yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.