https://www.juliafordatascience.com/first-steps-5-pluto/ Julia For Data Science * Home * Julia Quickstart Subscribe first steps First Steps #5: Pluto.jl * Josh Day Josh Day Apr 29, 2021 * 4 min read First Steps #5: Pluto.jl What's Pluto? Notebook environments (e.g. Jupyter and Observable) have become extremely popularity in the last decade. They give programmers a way to intersperse code with markup, add interactive UI elements, and show off code in a format more interesting than text files. People love them (well, not everyone). Pluto.jl is a newcomer (PlutoCon 2021 was just held to celebrate its one-year anniversary!) to the world of notebook environments. It provides a reactive environment specific to Julia. People are doing some very cool things with Pluto. Check out MIT's Introduction to Compuitational Thinking course for some fantastic public lectures with Pluto. Pluto Quickstart * Installing Pluto: ] add Pluto * Starting the Pluto Server: using Pluto Pluto.run() * The above command will open up the following page. WelcomePluto Welcome Screen * To get back to this page from an opened notebook, click the Pluto.jl icon in the top navbar. * For a deeper introduction to Pluto, go through the sample notebooks (we highly recommend them!). * Press ctrl + ? to view keyboard shortcuts: [Screen-Shot-2021-04-28-at-4] Key Points about Pluto 1. Your Code is Reactive. When you change a variable, that change gets propagated through all cells which reference that variable. [Apr-28-2021-16-05-47] 2. Returned Values will Render as HTML. That means things like the markdown string macro (md) will look nice. Note that output gets displayed above the code. [Screen-Shot-2021-04-28-at-4] 3. Code can be Hidden. Click the eye icon on the top left of a cell to hide the code. It only appears if your cursor is hovering over the cell. [Apr-28-2021-16-22-56] 4. You can @bind HTML Inputs to Julia Variables. Here we are using Pluto.@bind along with the html string macro to create a simple text input and bind it to a Julia variable my_input. The @bind macro works with any HTML input type. [Apr-28-2021-16-28-24] 5. You can Avoid Writing HTML by using PlutoUI. * First: ] add PlutoUI * Then: [Apr-28-2021-16-33-07] * To see all of the UI options in PlutoUI, open the PlutoUI.jl sample notebook. Notes, Tips, and Tricks Multiple Expressions * Pluto will try to get you to split multiple expressions into multiple cells (You can also put multiple expressions in a begin-end block). This helps Pluto manage the dependencies between cells and avoids unnecessary re-running of code that "reacts" to something it doesn't need to. Custom Display Methods * If you want something to make use of Pluto's rich HTML display, you need to define your own Base.show method for the text/html MIME type. [Screen-Shot-2021-04-28-at-4] Interpolating UI Elements into Markdown You can use Julia's string interpolation syntax to interpolate values into a markdown block that will then get rendered as HTML. This includes html strings and PlutoUI elements! You can even define the UI element somewhere else to keep your markdown block look cleaner. x_ui = @bind x Slider(1:10) md"My UI Element: $x_ui" # Provides the same result: md"My UI Element: $(@bind x Slider(1:10))" [Apr-28-2021-17-02-38]Cool Little Pluto UI Final Thoughts On a personal note, I've found Pluto particularly useful for making: 1. Lightweight user interfaces for customers without strong Julia skills. I simply teach the customer to run Pluto.run() and then I don't need to deal with the overhead of developing a full web app. The downside is that Pluto notebooks can't (yet) be deployed as a web app. 2. Interactive presentations. Pluto works great for demonstrating code and more. A huge benefit is that thanks to reactivity, you'll never get in an awkward state with cells run out of order! 3. Data Visualization. Data visualization is often an iterative process that takes many incremental changes to get the plot you want. The reactivity of Pluto provides instant feedback and greatly speeds up this process. That's It! You now know how to do some really cool stuff with Pluto. What will you build with it? Enjoying Julia For Data Science? Please share us with a friend and follow us on Twitter at @JuliaForDataSci. Additional Resources * https://github.com/fonsp/Pluto.jl * PlutoCon 2021 * Introduction to Computational Thinking - MIT * Pluto's example notebooks! Sign up for more like this. Enter your email Subscribe First Steps #4: Digging Into DataFrames First Steps #4: Digging Into DataFrames DataFrames.jl provides the most widely used tabular data structure in Julia. In this post we'll explore DataFrames using sample data from RDatasets.jl (and we'll plot stuff using StatsPlots). A rather timely event: DataFrames.jl has reached version 1.0![?][?] SetupFirst, install DataFrames and RDatasets via Pkg Mode (]) in * Josh Day Josh Day Apr 22, 2021 * 4 min read Julia Quickstart Julia Quickstart Enjoying Julia For Data Science? Please share us with a friend and follow us on Twitter at @JuliaForDataSci.For this article, we're taking a break from the First Steps series. This is something between a FAQ and lightning-fast introduction to Julia. Think of it as "First Steps #0: I've heard * Josh Day Josh Day Apr 13, 2021 * 6 min read First Steps #3: A Primer on Plots First Steps #3: A Primer on Plots This post #3 in our First Steps series. Want to learn Julia but don't know where to start? Start here! * Josh Day Josh Day Apr 5, 2021 * 4 min read Julia For Data Science (c) 2021 * Privacy Powered by Ghost