Julia Plots has no output in Jupyter notebook - jupyter-notebook

I'm trying to plot a geometric sum (for teaching purposes), and am getting no output for certain input values.
This is run using Julia 1.3 on MacOS Mojave 10.14.5 using an up-to-date version of Chrome
Here is the code:
using Plots
geom_series(x,n)=sum([x.^m for m in 0:n])
n=14
x=LinRange(-2.0,4.0,1001)
y=geom_series(x,n)
plot(x,y, ylims=(-10,10))
This plots fine in Jupyter notebook for n in 1:13. Thereafter, it plots for any odd n, but for no even n. It will also plot if I reduce the domain (e.g. x= LinRange(-2.0,2.0,1001)) or if I remove the ylims from the plot statement.
This involves some very large y-values, for both odd and even n. I've checked for NaNs, but there aren't any.
It also runs perfectly well if I run the code in the REPL.
Also no problems if I use PyPlot instead of Plots, so it is not a serious issue for me.
But does anyone have some idea of what might be going on?

Related

Histogram in Julia: Distributed.ProcessExitedException

I'm running Julia 1.7.2 in a Pluto notebook on an M1 chip.
I have a vector of integers between 1 and 9, and would like to make a histogram showing which integers are most frequent.
I thought I had done this successfully by using Plots and then calling histogram on the appropriate vector. At one point I had even generated a plot that I liked doing this.
I then tried to replicate this procedure (i.e. using Plots, and then call histogram) in a different Pluto notebook I had written.
I don't know if it was conflicting with other packages, but I began to get Distributed.ProcessExitedException errors in this other notebook when I ran histogram.
In another fail mode, I created a cell that contained only the following code
begin
using Plots
histogram(vector)
end
When I run the notebook with this code, all the other cells evaluate, but then this last cell lags forever and does not evaluate.
Frustrated, I went back to the first notebook where I had gotten the plotting to work, but now I get Distributed.ProcessExitedException error there too!
I am just posting to see if anyone has any ideas as to what might be going on.
In particular,
is there a link between Plots and Distributed?
is there anything that would cause an error in one notebook to cause a different notebook that had previously been working to fail?
The packages I was using in the first notebook that worked, and then didn't work) were
begin
using DataFrames
using BSON
using Revise
using FileIO
using CSV, HDF5, NRRD
# Statistics
using StatsBase: mean, nquantile, percentile
using LinearAlgebra: norm, mul!
using HypothesisTests
using Plots
using Random
# Tensors
using Tullio: #tullio
# Algorithms
import Flux
import Flux: update!
using Flux: RMSProp
end
The packages I was using in the second notebook that never worked were
begin
using DataFrames
using FileIO
using CSV, HDF5, NRRD
# Statistics
using StatsBase: mean, nquantile, percentile
using LinearAlgebra: norm, mul!
using HypothesisTests
# Tensors
using Tullio: #tullio
# Algorithms
import Flux
import Flux: update!
using Flux: RMSProp
end

Is it possible to benchmark an entire JupyterLab Notebook?

I'm not sure if this is a CV question or SO, so I apologize if it falls within the CV domain.
Problem
I know it's possible to microbenchmark specific chunks of R code, but is there any benchmark-ing tool for an entire Jupyter Notebook? I could just run the entire notebook and time it manually, but I'd like more statistics and precision on the timing for which the microbenchmark package provides (I'm trying to make a case for automation of data analyses and visualizations).
The other dilemma (an overall issue with notebooks) is that my notebook is divided into many individual cells, so the option of benchmark-ing in the Jupyter environment might be inefficient (forcing me to export all code and then running a microbenchmark on it say in R Studio).
Desired Solution
An efficient way to benchmark an entire, multi-celled JupyterLab Notebook.

Drawing a clinical study subjects flow chart directly in R within a Jupyter notebook

I'm using R (3.x) within Jupyter to perform some statistical analysis of a clinical study.
The flow of subjects is pretty complex and I would like to draw the Patient flow chart directly in my notebook. Like this one :
Why ?
To make sure the subjects count is consistent with the code, and not having to maintain sync between the R code and this figure.
I've tried DiagrammeR (won't install for some reason), RGrahpviz (too complex and doesn't meet the requirements).
A perfect solution might come from mermaid but I couldn't find a way to have it integrated with my Jupyter/R notebooks.
I'm not using a python Jupyter notebook but a R notebook.
You have mentioned that DiagrammeR won't install, but I would still provide one solution using DiagrammeR anyway--in case you have solved the installation issue. Suppose after you have made the graph using DimagrammeR and obtained a grViz object named myGraph. To display it under jupyter notebook, I use the following
require('DiagrammeR')
require('DiagrammeRsvg') #export grViz objects to svg
require('IRdisplay')
mySVG<-export_svg(myGraph)
display_svg(data=mySVG)

Silhouette not working in r

Running R 3.5.1 in R Studio.
I’ve edited pam.res$clustering to manually change the clusters.
Used silhouette() to try to observe the silhouette info for the edited clustering:
mahal<-D2.dist(data, cov.wt(data)$cov)
newsil<-silhouette(pam.res$clustering, mahal)
And all I get from summary(newsil) is
Mode NA’s
logical 1
I can’t reference within newsil, as it’s an atomic vector, which it shouldn’t be.
Can’t figure out what’s gone wrong. Any ideas? Thanks.

R Eclipse StatET - Creating wordcloud gets overlapped words

I'm trying to create a wordcloud using R in Eclipse. I've been working with R for some weeks without any problem and I´ve created lots of different plots, but when creating the wordcloud, any kind of them and using different configurations, I always get the wordcloud with all the words overlapped.
I've followed different examples and I always get the words overlapped. For example, if I execute this code:
library(wordcloud)
library(tm)
wordcloud("May our children and our children's children to a
thousand generations, continue to enjoy the benefits conferred
upon us by a united country, and have cause yet to rejoice under
those glorious institutions bequeathed us by Washington and his
compeers.",colors=brewer.pal(6,"Dark2"),random.order=FALSE)
I get this result:
As you can see, all the words are overlapped and I don´t know what to do. I've search a lot on the Internet and I didn't get any clue.
The arguments within the wordcloud package includes:
"use.r.layout - if false, then c++ code is used for collision detection, otherwise R is used"
-Documentation for Wordcloud package.
There may be some difficulty with Eclipse and the usage of R vs. C++. As I am unsure as to the default of Wordcloud try toggling the argument between TRUE and FALSE.
e.g. Wordcloud("Corpus",use.r.layout=TRUE,colors=brewer.pal(6,"Dark2"),random.order=FALSE)
I got this problem after adding the command
Sys.setlocale('LC_ALL','C')
Disabling this directive made wordclouds work fine again.
I am using Jupyter Notebook with R kernel

Resources