How to install/import MakieLayout - plot

I'm trying to run this simple example, taken directly from the official documentation
using AbstractPlotting.MakieLayout
using AbstractPlotting
scene, layout = layoutscene(resolution = (1200, 900))
ax = layout[1, 1] = LAxis(scene, xlabel = "x label", ylabel = "y label",
title = "Title")
But I get an error at line 1: MakieLayout not defined
I have successfully installed Makie (v0.11.0) and AbstractPlotting (v0.11.2). I still managed to run the example by installing and importing MakieLayout as a separate package but MakieLayout as a package is deprecated and should have been absorbed by AbstractPlotting.
My questions are:
Am I doing something wrong here?
Is this an isolated issue or do other people have the same problem?
I would really appreciate some help if someone knows what is going on here.

AbstractPlotting's current version (Nov 5 2020) is 0.13.5. I recommend updating it before trying to use AbstractPlotting.MakieLayout.
You can update this package by doing
] update AbstractPlotting
If it is not correctly updated, it is possible that some other package is holding it back.
To discover what package is holding it back you can try to add the specific version by doing
] add AbstractPlotting#0.13.5
And you will get a more informative error message.
I advice you to remove the MakieLayout package before updating since this is obsolete and it is probably holding AbstractPlotting's version back.
EDIT (6 November 2020):
Nowadays it is not necessary to install the Makie.jl package. You can safely remove it and add instead:
AbstractPlotting
And one or more of the backends:
GLMakie (] add GLMakie), the fastest and more complete, uses GPU
CairoMakie (] add CairoMakie) if you don't have GPU or want to output to vector graphics
WGLMakie (] add WGLMakie)
the package called Makie is just AbstractPlotting + GLMakie and I think it is on its way out. You should remove the package and change your first line to:
using AbstractPlotting, GLMakie #or your selected backend
using AbstractPlotting.MakieLayout
Information about managing versions and packages can be found here

Related

How to get rid of a size warning in R for package development

I am working on submitting an R package and when I run
devtools::check()
I get the following warning:
W checking sizes of PDF files under ‘inst/doc’ (1.6s)
‘gs+qpdf’ made some significant size reductions:
compacted ‘Vignette1.pdf’ from 544Kb to 256Kb
compacted ‘Vignette2.pdf’ from 328Kb to 69Kb
consider running tools::compactPDF(gs_quality = "ebook") on these files
I understand that the size of the PDFs are the issue, and that they need to be resized, but can anyone explain to me where I need to place tools::compactPDF(gs_quality = "ebook") in my code so that when the vignettes are created this is not an issue. You cannot submit an R package that throws a warning so I need to come up with a solution to fix this.
If you do R CMD build --help you will see the two lines
--compact-vignettes= try to compact PDF files under inst/doc:
"no" (default), "qpdf", "gs", "gs+qpdf", "both"
Per recent discussion on the mailing lists, you may want arguments gs+qpdf or both. You may want to experiment with both. Use of the option should render a package that does not trigger the NOTE.
And I presume there is a way to pass that onto devtools as well but I am not familiar with its functions so I can't give you a direct pointer.
As of devtools 2.4.5
devtools::check(build_args = "--compact-vignettes=gs+qpdf")
is the correct parameterization. But note that for building, the corresponding call is now
devtools::build(args = "--compact-vignettes=gs+qpdf")
Note that in neither case do you quote the argument passed down to R CMD BUILD's --compact-vignettes

Can't plot step response in Octave

Iam trying to plot step response in Octave (v 4.0.3) using this code:
pkg load control
clf;
s = tf('s');
g = 1/(2*s^2+3*s+4);
step(g);
But I get always the same error:
error: matrix cannot be indexed with .
error: called from
plot at line 198 column 7
__time_response__ at line 207 column 13
step at line 74 column 10
If I used the same code in another computer with Octave 5.0.2 the code works perfectly, so I guess this is some kind of problem with this version.
I just want to know if there is some kind of workaround to plot my step response, cause this I need this particular version of Octave, so upgrade it is not a solution for my right now.
Thanks!
plot has likely changed quite a bit since that old version of Octave came out, and you didn't mention the package version, but I'm guessing you are probably trying to use a current version of control? The newest version would have been coded to accommodate any changes in Octave since then. Best bet might be to try to uninstall the control package (pkg uninstall control) and find an old version from around the same time as Octave 4.0.3.
According to the Octave Major Release History page, 4.0.3 came out on 2016-07-01. Looking at the Control Package News page, you probably want to try control-3.0.0, Release Date: 2015-10-30. (the next version was in 2018 right around Octave 4.2.2, and might also work. I didn't see a note about the plot or step function behavior changing, so you might have to try a couple versions to find one that works with plot from 4.0.3.)
The Octave Control Package page has a link to Older Versions which just takes you to the SourceForge file host. Navigating from there to Octave Forge Packages, individual package releases, will give you a chronological package download list where you can find different control packages to try. Scroll down or do a Find for 'control' and you should see 3.0.0 there.

R CMD check: no visible binding for global variable (when using a data/ dataset in the package)

Slightly different versions of this question have been asked before but I haven't seen a good answer yet.
I have a very simple repro using the very good source code of ggplot2:
Go into any file in ggplot2/R/ and add a line that references the "diamonds" dataset included in ggplot2/data/diamonds.r.
Then attempt to build/check the package, (ie: R CMD build .; R CMD check --as-cran ggplot2_3.0.0.9000.tar.gz)
In my arbitrary example I added diamonds to line 436 in theme.r and got this note when trying to check:
* checking R code for possible problems ... NOTE
plot_theme: no visible binding for global variable ‘diamonds’
Undefined global functions or variables:
diamonds
I run into this problem in our package which we want to submit to CRAN. AFAIK we are following best practices by using data/ourdataset.r and then "ourdataset" in our R/ code. And yet, we get this NOTE failure.
What are we doing wrong? If this NOTE comes up for a package like ggplot2, I am at a loss as to whether we are doing something wrong or this is something that should be fixed in CHECK. CHECK has been fantastic so far but I am stumped on this one.
Thanks!
Usually, to get rid of that Note you just have to add a reference like this:
ggplot2::diamonds

Split an R package into two packages without disrupting users

Suppose I'm currently developing a package called mypackage. As time goes by, many different functions have landed in there, and I want to reorganize it. So I'd like to create a new package called newpackage in which I would move some of the functions of mypackage (and include new ones later).
The problem is that I don't want original users of mypackage to get object not found errors when they want to use one of the moved functions.
So, I thought about doing the following :
create newpackage and move the functions
add into mypackage DESCRIPTION file : Depends: newpackage
As such, when people would install, upgrade or load mypackage, newpackage would be installed or loaded too, and all the functions would be available.
Do you think it would work, or would there be some problems I don't think about ?
Thanks !
Isn't it so that it is not recommended to remove functions from a package without labeling them first to be depreciated?! So, maybe you proceed as you planned but before removing them from the mypackage, you could first mark them there as depreciated and then remove them from it finally in the next version of the package. And during the migrating phase you could use the namespace of the packages to refer already to the function in newpackage as you planned.

How do I resuscitate a ggplot that was saved to disk inside a list?

I created several hundred plots using ggplot and saved them all to a list. I saved the list to disk using:
save(list_of_plots,file="list_of_plots.rdata")
Now I want to display those plots and save some using ggsave. However, calling a list item just shows me components of the plot.
> names(plots00_t2[[1]])
[1] "data" "layers" "scales" "mapping" "options"
[6] "coordinates" "facet" "plot_env"
Update: My dumb mistake was not loading ggplot2 when I reopened these files. However, when attempting to display these plots, I get:
Error in get("make_aesthetics", env = x, inherits = TRUE)(x, ...) :
could not find function "calc_aesthetics"
So short of recreating these plots, how would I fix this?
the last version using the internal function calc_aesthetics was ggplot2 version 0.8.2. If possible, check which version of ggplot2 is used for creating the plots and load that one. Otherwise, try with version 0.8.2 or earlier.
Download the file from http://cran.r-project.org/src/contrib/Archive/ggplot2/ and save it somewhere on your computer (I used G:/Temp here). Then use this code to install and call the specific version :
install.packages(
"G:Temp/ggplot2_0.8.2.tar.gz",
lib="G:/Templibs",
repos=NULL,
type="source")
library(ggplot2,lib.loc="G:/Templibs")
After this, you should be able to print the graphs. See also this question and the help files of ?library and ?install.packages
It might happen that the code of ggplot2 was changed in meanwhile and "calc_aesthetics" is no longer available. In this case you should install an older version of ggplot2, to recover your work.
Though, the above is quite unlikely. The problem seems to stem from the fact that some parts of your plots have not been saved properly.
You should produce the traceback(), it might cast some light on the problem.

Resources