Movatterモバイル変換


[0]ホーム

URL:


Version:4.2.3
Title:Interface to 'Altair'
Description:Interface to 'Altair'https://altair-viz.github.io, which itself is a 'Python' interface to 'Vega-Lite'https://vega.github.io/vega-lite/. This package uses the 'Reticulate' frameworkhttps://rstudio.github.io/reticulate/ to manage the interface between R and 'Python'.
SystemRequirements:Python (>= 3.6.0), (Python) Altair (>= 4.2.0),vega_datasets (>= 0.9.0). To use image functions for MacOS: X11
License:MIT + file LICENSE
Encoding:UTF-8
ByteCompile:true
URL:https://github.com/vegawidget/altair
BugReports:https://github.com/vegawidget/altair/issues
Imports:reticulate (≥ 1.23), htmlwidgets, assertthat, magrittr,utils, vegawidget (≥ 0.4.1), repr
Suggests:httr, rprojroot, purrr, readr, knitr, rmarkdown, tibble,listviewer (≥ 2.0.0), testthat, pryr, stringr, tidyr, dplyr,pkgdown, V8, rsvg, png, fs
RoxygenNote:7.2.3
NeedsCompilation:no
Packaged:2023-09-04 01:22:53 UTC; ijlyttle
Author:Ian LyttleORCID iD [aut, cre], Haley Jeppson [aut], Altair Developers [aut], Alicia SchepORCID iD [ctb], Jake Vanderplas [ctb] (Altair library), Brian Granger [ctb] (Altair library)
Maintainer:Ian Lyttle <ijlyttle@me.com>
Repository:CRAN
Date/Publication:2023-09-04 03:50:02 UTC

altair: Create and embed Vega-Lite charts using the Altair Python package

Description

The goal of altair is to help you buildVega-Lite visualizations. Using thereticulate package, it providesan interface to theAltair Python package.

Details

In this documentation, the capitalized wordAltair shall refer to thePython package; the lower-case wordaltair shall refer to this R package.

Author(s)

Maintainer: Ian Lyttleijlyttle@me.com (ORCID)

Authors:

Other contributors:

See Also

altair pkgdown website,Altair Python package,Vega-Lite


Pipe operator

Description

Seemagrittr::%>% for details.

Usage

lhs %>% rhs

Mark character strings as literal JavaScript code

Description

This function is re-exported from the htmlwidgets package.Seehtmlwidgets::JS() for more details.

Usage

JS(...)

See Also

htmlwidgets::JS()


Altair object

Description

Uses the reticulate framework to access the Altair API.

Usage

alt

Format

An object of classpython.builtin.module (inherits frompython.builtin.object) of length 1.

Details

The Altair Python package is exposed through thealt object.You can create and add to chart using its methods and classes,as outlined in theAltair Python documentation.

In this package, use the$ operator wherever you see the. operatorused in Python.

See Also

Altair Python documentation,altair: Field Guide to Python Issues

Examples

if (interactive()) {  vega_data <- import_vega_data()  plot_basic <-    alt$Chart(vega_data$cars())$    encode(      x = "Miles_per_Gallon:Q",      y = "Horsepower:Q",      color = "Origin:N"    )$    mark_point()   plot_basic}

Altair plot concatenation

Description

Altair plots can be concatenated using the following operators:+,|, and&

Usage

## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'e1 | e2## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'e1 + e2## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'e1 & e2

Arguments

e1

Altair chart object

e2

Altair chart object

Value

Compound Altair chart object

Examples

if (interactive()){  # Examples using the beaver1 and beaver2 body temperature data sets  # Layering Charts  base <- alt$Chart(beaver1)$encode(    x = alt$X('time'),    y = alt$Y('temp', scale = alt$Scale(zero = FALSE))  )  scatter_plot <- base$mark_point()  line_plot <- base$mark_line()  combined_plot <- scatter_plot + line_plot  # Horizontal Concatenation  base2 <- alt$Chart(beaver2)$    encode(      x = alt$X("time"),      y = alt$Y("temp", scale = alt$Scale(zero = FALSE))    )  scatter_plot2 <- base2$mark_point()  line_plot2 <- base2$mark_line()  combined_plot <-    (scatter_plot + line_plot)$    properties(title = "Beaver 1", width = 200)  combined_plot2 <-    (scatter_plot2 + line_plot2)$    properties(title = "Beaver 2", width = 200)  hconcat_plot <- combined_plot | combined_plot2  # Vertical Concatenation  vconcat_plot <- combined_plot & combined_plot2}

Installed versions of Altair, Vega, etc.

Description

Returns a named list of version tags for Altair, Vega, Vega-Lite,and Vega-Embed

Usage

altair_version()

Value

namedlist of version tags

Examples

if (interactive()) {  altair_version()}

Create Altair chart from vegaspec

Description

Create Altair chart from vegaspec

Usage

as_chart(spec)

Arguments

spec

An object to be coerced tovegaspec, a Vega/Vega-Lite specification

Value

altair object

Examples

  if (interactive()) {    as_chart(vegawidget::spec_mtcars)  }

Coerce to vegaspec

Description

Seevegawidget::as_vegaspec for details.

Usage

## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'as_vegaspec(spec, ...)

Arguments

spec

An object to be coerced tovegaspec, a Vega/Vega-Lite specification

...

Other arguments (attempt to future-proof)


Check the Altair installation

Description

Provides feedback on any differences between your installedversion of Altair and the version this package supports.

Usage

check_altair(quiet = FALSE)

Arguments

quiet

logical, ifTRUE, suppresses message upon successful check

Details

If the supported Altair version is different from your installedversion, this function will act according to where thedifference in the version numbers:

If there is no difference:

To install the supported version into a Python environmentcalled"r-reticulate", useinstall_altair().

Value

invisibleNULL, called for side-effects

See Also

reticulate::py_config(),install_altair(),altair_version()

Examples

## Not run:   # not run because it requires Python  check_altair()## End(Not run)

Create or write image

Description

Seevegawidget::image for details.


Import Vega datasets

Description

Lets you access Vega datasets.

Usage

import_vega_data()

Details

Returns thedata object in the Python packagevega-datasets.In the documentation for this package, the convention is toassign this object to the namevega_data.

Value

An S3 object of classvega_datasets.core.DataLoader

See Also

Vega datasets documentation

Examples

if (interactive()) {  vega_data <- import_vega_data()  # To list available datasets  print(vega_data$list_datasets())  # When accessing a dataset, substitute any "-" in the name with a "_"  print(head(vega_data$sf_temps()))  # Metadata are available for each dataset:  print(vega_data$anscombe$references)  print(vega_data$anscombe$description)  print(vega_data$anscombe$url)  # For local datasets, local path is available  print(vega_data$sf_temps$filepath)}

Install Altair Python package

Description

This function wraps installation functions fromreticulate to install the Python packagesaltair andvega_datasets.

Usage

install_altair(  method = c("conda", "virtualenv"),  envname = "r-reticulate",  version = getOption("altair.python.version"),  ...)

Arguments

method

character, indicates to use"conda" or"virtualenv"

envname

character, name of environment into which to install

version

character, version of Altair to install. For general use of this package,this is set automatically, so you should not need to specify this.

...

other arguments sent toreticulate::py_install()

Details

This package uses thereticulate packageto make an interface with theAltairPython package. To promote consistency in usage ofreticulate amongdifferent R packages, it isrecommendedto use a common Python environment, called"r-reticulate".

Depending on your setup, you can create this environment usingreticulate::conda_create() orreticulate::virtualenv_create(),as described in thisreticulate article,or in this package'sInstallation article.

Value

invisibleNULL, called for side-effects

See Also

altiar: Installation,reticulate: Using reticulate in an R Package,reticulate: Installing Python Packages

Examples

## Not run:   # not run because it requires Python  install_altair()## End(Not run)

Knit-print method

Description

Seevegawidget::knit_print.vegaspec for details,particularly on additional packages that may have to be installed.

Usage

knit_print.altair.vegalite.v4.api.TopLevelMixin(spec, ..., options = NULL)

Arguments

spec

An object to be coerced tovegaspec, a Vega/Vega-Lite specification

...

other arguments

options

list, knitr options


Render shiny-output for vegawidget

Description

Deprecated, please usevegawidget::renderVegawidget.

Usage

renderVegawidget(expr, env = parent.frame(), quoted = FALSE)

Arguments

expr

expression that generates a vegawidget. This can beavegawidget or avegaspec.

env

The environment in which to evaluateexpr.

quoted

Isexpr a quoted expression (withquote())? Thisis useful if you want to save an expression in a variable.


MIME method for text

Description

MIME method for text

Usage

## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'repr_text(obj, ...)

Arguments

obj

Altair chart object to be rendered

Value

character


MIME method for chart rendering

Description

MIME method for chart rendering

Usage

## S3 method for class 'altair.vegalite.v4.api.TopLevelMixin'repr_vegalite4(obj, ...)

Arguments

obj

Altair chart object to be rendered

Value

list, reflecting JSON spec


Vega embed options

Description

Seevegawidget::vega_embed for details.


Create a Vega/Vega-Lite htmlwidget

Description

Seevegawidget::vegawidget for details.


Shiny-output for vegawidget

Description

Deprecated, please usevegawidget::vegawidgetOutput.

Usage

vegawidgetOutput(outputId, width = "auto", height = "auto")

Arguments

outputId

output variable to read from

width,height

Must be a valid CSS unit (like"100%","400px","auto") or a number, which will be coerced to astring and have"px" appended. For vegawidgets,"auto" is usefulbecause, as of now, the spec determines the size of the widget, then thewidget determines the size of the container.


Coerce vegaspec to JSON

Description

Deprecated, please usevegawidget::vw_as_json.

Usage

vw_as_json(spec, pretty = TRUE)

Arguments

spec

An object to be coerced tovegaspec, a Vega/Vega-Lite specification

pretty

logical indicates to use pretty (vs. minified) formatting

Value

jsonlite::json object


Set base URL

Description

Seevegawidget::vw_set_base_url for details.


[8]ページ先頭

©2009-2025 Movatter.jp