Skip to content

Commit

Permalink
Add flexplot (#256)
Browse files Browse the repository at this point in the history
* Add flexplot

* Add po files
  • Loading branch information
boutinb authored Apr 11, 2024
1 parent 7851ed1 commit 320b344
Show file tree
Hide file tree
Showing 21 changed files with 2,343 additions and 5 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Imports:
ggrepel,
jaspBase,
jaspGraphs,
forecast
forecast,
flexplot
Remotes:
jasp-stats/jaspBase,
jasp-stats/jaspGraphs
jasp-stats/jaspGraphs,
dustinfife/flexplot
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export(.tsFillTimeSeriesPlot)
export(.tsFillACF)
export(DescriptivesTimeSeries)
export(DescriptivesTimeSeriesInternal)

export(flexplot)
export(flexplotInternal)
3 changes: 3 additions & 0 deletions R/flexplot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flexplotInternal <- function(jaspResults, dataset, options) {
return(flexplot:::flexplot_jasp2(jaspResults, dataset, options))
}
66 changes: 66 additions & 0 deletions R/flexplotWrapper.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Copyright (C) 2013-2022 University of Amsterdam
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This is a generated file. Don't change it

flexplot <- function(
data = NULL,
version = "0.18.3",
formula = NULL,
alpha = 0.4,
bw = FALSE,
confidence = FALSE,
dependent = "",
ghost = TRUE,
intervals = "Quartiles",
jitx = 0.1,
jity = 0,
nameCols = "",
nameLegend = "",
nameRows = "",
nameX = "",
nameY = "",
palette = "GGplot Default",
paneledVars = list(),
plotHeight = 320,
plotWidth = 480,
theme = "JASP",
type = "Loess",
variables = list()) {

defaultArgCalls <- formals(jaspDescriptives::flexplot)
defaultArgs <- lapply(defaultArgCalls, eval)
options <- as.list(match.call())[-1L]
options <- lapply(options, eval)
defaults <- setdiff(names(defaultArgs), names(options))
options[defaults] <- defaultArgs[defaults]
options[["data"]] <- NULL
options[["version"]] <- NULL

if (!is.null(formula)) {
if (!inherits(formula, "formula")) {
formula <- as.formula(formula)
}
options$formula <- jaspBase::jaspFormula(formula, data)
}

optionsWithFormula <- c("dependent", "intervals", "palette", "paneledVars", "theme", "type", "variables")
for (name in optionsWithFormula) {
if ((name %in% optionsWithFormula) && inherits(options[[name]], "formula")) options[[name]] = jaspBase::jaspFormula(options[[name]], data) }

return(jaspBase::runWrappedAnalysis("jaspDescriptives::flexplot", data, options, version))
}
7 changes: 7 additions & 0 deletions inst/Description.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ Description
title: qsTr("Time Series Descriptives")
func: "DescriptivesTimeSeries"
}

Analysis
{
title: qsTr("Flexplot")
qml: "Flexplot.qml"
func: "flexplot"
}
}
4 changes: 4 additions & 0 deletions inst/qml/Flexplot.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import QtQuick
import "common" as COMMON

COMMON.FlexplotForm {}
210 changes: 210 additions & 0 deletions inst/qml/common/FlexplotForm.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import QtQuick
import JASP.Controls
import JASP

Form
{
Formula
{
lhs: "dependent"
rhs: "variables"
}

VariablesForm
{
AvailableVariablesList { name: "allVariables" }
AssignedVariablesList {
name: "dependent" ;
title: qsTr("Dependent Variable") ;
singleVariable: true
onCountChanged: nameY.value = count > 0 ? model.data(model.index(0,0)) : ""
}
AssignedVariablesList {
name: "variables" ;
title: qsTr("Independent Variable(s)") ;
id: varlist
onCountChanged: {
nameLegend.value = count > 1 ? model.data(model.index(1,0)) : "";
nameX.value = count > 0 ? model.data(model.index(0,0)) : "";
}

}
AssignedVariablesList {
name: "paneledVars" ;
title: qsTr("Paneled Variable(s)");
id: paneledVars
onCountChanged: {
nameCols.value = count > 0 ? model.data(model.index(0,0)) : "";
nameRows.value = count > 1 ? model.data(model.index(1,0)) : "";
}

}
}

Section
{
title: qsTr("Options")

Group
{
title: qsTr("<br><strong>Point controls</br></strong>")
columns: 4
Slider
{
name: "alpha"
label: qsTr("Point transparency")
value: 0.4
vertical: true
enabled: varlist.count > 0
}
Slider
{
name: "jitx"
label: qsTr("Jitter in X")
value: .1
min: 0
max: .5
vertical: true
enabled: varlist.count > 0
}
Slider
{
name: "jity"
label: qsTr("Jitter in Y")
value: 0
min: 0
max: .5
vertical: true
enabled: varlist.count > 0
}
}
Group
{
Group
{
title: qsTr("<strong>Visual Statistics</strong>")
CheckBox
{
name:"confidence";
label: qsTr("Plot confidence bands")
enabled: varlist.count > 0
}
DropDown
{
name: "type"
values:
[
{label: qsTr("Loess"), value: "Loess"},
{label: qsTr("Regression"), value: "Regression"},
{label: qsTr("Quadratic"), value: "Quadratic"},
{label: qsTr("Cubic"), value: "Cubic"},
{label: qsTr("None"), value: "None"}
]
label: qsTr("Fitted line (scatterplots)")
enabled: varlist.count > 0
}
DropDown
{
name: "intervals"
values:
[
{label: qsTr("Quartiles"), value: "Quartiles"},
{label: qsTr("Standard errors"), value: "Standard errors"},
{label: qsTr("Standard deviations"), value: "Standard deviations"}
]
label: qsTr("Intervals (categorical predictors)")
enabled: varlist.count > 0
}
}

Group
{
title: qsTr("<br><strong>Other Plot Controls</strong>")
DropDown
{
name: "theme"
values:
[
{label: qsTr("JASP"), value: "JASP"},
{label: qsTr("Black and white"), value: "Black and white"},
{label: qsTr("Minimal"), value: "Minimal"},
{label: qsTr("Classic"), value: "Classic"},
{label: qsTr("Dark"), value: "Dark"}
]
label: qsTr("GGplot theme")
}
DropDown
{
name: "palette"
values:
[
{label: qsTr("GGplot Default"), value: "GGplot Default"},
{label: qsTr("Nature"), value: "Nature"},
{label: qsTr("AAAS"), value: "AAAS"},
{label: qsTr("Lancet"), value: "Lancet"},
{label: qsTr("JCO"), value: "JCO"},
{label: qsTr("Dark"), value: "Dark"}
]
label: qsTr("Color Palette")
}
CheckBox
{
name:"bw";
label: qsTr("Convert to grayscale");
checked: false
}

CheckBox
{
name:"ghost";
label: qsTr("Ghost lines");
checked: true
enabled: paneledVars.count > 0
}
}
}
}

Section
{
title: qsTr("Plot Labels")
Group
{
title: qsTr("<br><strong>Plot Labels</strong>")
TextField
{
id: nameX;
label: qsTr("X Axis Label");
name: "nameX";
}
TextField
{
id: nameY
label: qsTr("Y Axis Label")
name: "nameY";
value: xAxis.value
}
TextField
{
id: nameLegend
label: qsTr("Legend Label")
name: "nameLegend";
value: legend.value
}
TextField
{
id: nameCols
label: qsTr("Column Panel Label")
name: "nameCols";
value: cols.value
}
TextField
{
id: nameRows
label: qsTr("Row Panel Label")
name: "nameRows";
value: rows.value
}
}
}
}
1 change: 1 addition & 0 deletions inst/qmldir
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module <jaspDescriptives>
DescriptivesTimeSeriesForm 1.0 qml/common/DescriptivesTimeSeriesForm.qml
FlexplotForm 1.0 qml/common/FlexplotForm.qml
Loading

0 comments on commit 320b344

Please sign in to comment.