Draggable axis sliders in Julia - julia

I am trying to replicate this plot in Julia. The idea is to be able to drag the x-axis using a slider. The closest code that I found to replicate this is shown below:
## Interact.WebIO.install_jupyter_nbextension() # might be helpful if you see `WebIO` warnings in Jupyter
#manipulate throttle=.05 for λ=0:.1:5, μ=0:.1:5
xs = range(0.0, 1.0, length = 100)
Plots.plot(xs, x -> λ*x^2 + μ)
end
Is there any libraries that can do this easily? Thanks!

As folks mentioned in the comments, there's a few viable approaches to this. Interact.jl is definitely one of them. I would also suggest looking at Makie.jl: http://makie.juliaplots.org/stable/makielayout/slider.html which is a great tool for something like this and will solve your use case perfectly.

Related

How do I make gsea plot with group names labelled?

I am trying to plot gsea similar to image as given below:
the tutorial does not give you such plots. So I tried the github link.
But it failed to generate the similar plot
I checked both gseaplot2{enrichplot} and plotEnrichment{fgsea} and found no options to automatically add the group names. It might be a good idea to just add the names after exporting to Adobe Illustrator. Would be happy to hear other ideas though if anyone else knows a better way.

Quantization distortion in x-axis of GLMakie plot. Why?

I create a simple plot using GLMakie:
GLMakie.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )
The result looks like this:
Looks like the x-axis is heavily quantized. The Plots package handles the same command just fine:
Plots.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )
GLMakie can also handle the same plot if the x range is centered on 0:
GLMakie.scatter( range((-5e-9)..(5e-9),100), range(1..100,100) )
Why is this happening? Does GLMakie use a smaller float for speed? Can I do anything to avoid this?
Does GLMakie use a smaller float for speed?
Yes it does. OpenGL commonly uses 32 bit floats and Makie has been built with Float32 as a result. Right now you'd have normalize your data and adjust ticks manually to fix this. See https://makie.juliaplots.org/stable/examples/layoutables/axis/index.html#modifying_ticks
There are also a bunch of issues regarding this on github, for example https://github.com/JuliaPlots/Makie.jl/issues/1373.

Changing the font size in a DAG in R

I'm building a Bayesian network (DAG) in R, it has several nodes stemming from one parent, so it has a lot of nodes.
I can't seem to figure out how to increase the font size of the node labels (won't let me post image).
To plot it, I've just done plot(dag_pigment).
Where the input is this:
dag_pigment<-dag(c("pigment","1800407"),c("pigment","12203592"),c("pigment","12896399"),c("pigment","3829241"),c("3829241","12913832"), c("pigment","1408799"), c("1408799", "12913832"),c("pigment","683"),c("pigment","10777129"),c("pigment", "28777"),c("pigment", "16891982"),c("pigment", "6119471"), c("pigment", "1426654"),c("pigment", "1800414"),c("pigment", "4959270"),c("pigment", "2378249"),c("pigment", "12821256"),c("pigment", "1805007"))
I've tried using cex within the plot function, and all the other subcategories (cex.main, cex.sub,etc.)
I've tried using ps, and I've tried using par like par(ps=20,cex=1,cex.main=1).
Are there other functions I should be trying? A different plot function?
Appreciate any help! I'm still pretty new at figuring these things out.
Ok, I actually figured this out after several hours, so, I'm posting the answer to be helpful for anyone else who might be looking.
You have to use the attrs function:
dag_pigment.cust<-plot(dag_pigment,attrs=list(node=list(fontsize=60)))
and this increased the font.

Label individual points in Sage plot

This seems like a straightforward problem, yet I can't find a solution. In Sage, I've got about 30 sorted points for a scatter_plot, and I want to add the order position as a label. I know this is easy if I were working with a graph object, since I could use the vertex_labels option in plot. Is there a simple fix to get this to work for a scatter_plot, or would I need to do something like make the points vertices and keep track of the exact location of each point
Currently, you may have to use matplotlib directly or mess around with that method inside of Sage to get this. See here or here for some related questions.
I've opened Trac 20583 for this.

How to plot magnetic field lines in mathematica?

I am preparing for the exams, and I have spent couple of days trying to solve the task, but without success. Can someone show me how I solve this? The result should look like this:
You can use StreamPlot or VectorPlot
for 3D fields, there is no built-in command. However, you can use VectorPlot3D.
There is also a 3rd party code for 3D streamline plot that you can find here.

Resources