Compare commits
133 Commits
v1.1.2
..
bbs/compat
| Author | SHA1 | Date | |
|---|---|---|---|
| 0762a29de3 | |||
| d6af1da35a | |||
| bbbee44c66 | |||
| 9499cef25d | |||
| 7c8952fadf | |||
| 8b2d3e926a | |||
| fb40ed1f59 | |||
| e88654cca5 | |||
| a9b9b3c357 | |||
| 99c8bfe12d | |||
| 3eb2b783dc | |||
| a20b275eaf | |||
| c29694ae70 | |||
| ebc93b6935 | |||
| 7dcbe911b1 | |||
| c2df99cc66 | |||
| a992effa5e | |||
| e49eb9bc83 | |||
| f2d7d394bb | |||
| 87d40cd34d | |||
| 5f24f88f12 | |||
| 9c465b58db | |||
| ad4a00c055 | |||
| 54671c15d7 | |||
| fff8f84acf | |||
| 4d8ea50f69 | |||
| 43f31cbc98 | |||
| d98e76e36d | |||
| e2a5e40019 | |||
| 3c2c2c18d7 | |||
| 0ee1d867c9 | |||
| b145ea9ef5 | |||
| 73971896ee | |||
| f5f4128e30 | |||
| 70dfa52a9a | |||
| 2e53c57114 | |||
| 0485b1313a | |||
| f0f28086a9 | |||
| 580ac8a9d1 | |||
| 84fc6b0be0 | |||
| de81220c01 | |||
| ee1f948448 | |||
| 995c7d349e | |||
| 4389160a6a | |||
| 8c6295658b | |||
| a270e342b7 | |||
| 42e2266530 | |||
| 02e6d729c1 | |||
| baac9a0578 | |||
| b73dd46521 | |||
| 7bbb2070a7 | |||
| 8859518f2d | |||
| 7f063c71b5 | |||
| 1e9691a7c0 | |||
| e5269bcf95 | |||
| fdd76a6ca1 | |||
| d19525c269 | |||
| 593331dec2 | |||
| b780d90097 | |||
| 2f9ce790e4 | |||
| d8f4519b0c | |||
| 702e41f55d | |||
| 682ac29fcd | |||
| c6ce23d0af | |||
| 9ae7d2dd9d | |||
| 6ec05628d5 | |||
| f26ebdc2f1 | |||
| c97255fc08 | |||
| 9d1ede016b | |||
| 7eb8f2452c | |||
| 0a6e691222 | |||
| 238aca6a78 | |||
| 1f039b3adc | |||
| 219465d599 | |||
| 1963cee94a | |||
| ae43e05f6f | |||
| 5cd2ba7296 | |||
| 4a00018f25 | |||
| 32c725e770 | |||
| 4e2ee35125 | |||
| 35b0751714 | |||
| 28ebc0ccd8 | |||
| 3d693d88e0 | |||
| 6ddf31d465 | |||
| 5c1ea707ca | |||
| a6669f89a0 | |||
| 2a2d509c36 | |||
| fd4efb3f33 | |||
| e90ab0b898 | |||
| 44367c54da | |||
| 3273a65889 | |||
| 0aa606d835 | |||
| 40848e7432 | |||
| fe4cc4d58c | |||
| 56f90ffaf3 | |||
| dfb556339f | |||
| 61f5a7f437 | |||
| 3be9b8d076 | |||
| 2a138dee40 | |||
| 712ef74b81 | |||
| ba8ca424cf | |||
| c6784a779b | |||
| d667cb7e57 | |||
| 10a5c2ed1d | |||
| 8cce78c890 | |||
| 294ade8aad | |||
| a59e8411c9 | |||
| d973f437ef | |||
| d5ce2c1431 | |||
| 834e2a99e3 | |||
| f8e9e33347 | |||
| a0c7781296 | |||
| 2ea998983d | |||
| e44b220b84 | |||
| 756cccb114 | |||
| af9982b804 | |||
| 1b946a18d2 | |||
| a397bfd549 | |||
| d276ac6857 | |||
| 475d1c2398 | |||
| d6ae848aec | |||
| 8976fc4ae4 | |||
| 095191f8e6 | |||
| 83ad031c13 | |||
| 2b1673df6f | |||
| b867ad58f8 | |||
| 8b897c3460 | |||
| e5cb36af7a | |||
| cdaa10be27 | |||
| fe3813b5af | |||
| 311bbdc99b | |||
| c90fa4d63c | |||
| 04c1c6c0ed |
@@ -7,7 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please search existing issues to avoid duplicates.
|
||||
<!-- Please search existing issues to avoid duplicates. -->
|
||||
|
||||
## Details
|
||||
|
||||
@@ -28,5 +28,5 @@ inspectdr | | |
|
||||
### Versions
|
||||
|
||||
Plots.jl version:
|
||||
Backend version:
|
||||
Backend version (`]st -m`):
|
||||
Output of `versioninfo()`:
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
CI:
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
|
||||
env:
|
||||
GKS_ENCODING: "utf8"
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
julia_version:
|
||||
- 'nightly'
|
||||
- '1'
|
||||
- '1.0'
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
- macos-latest
|
||||
arch:
|
||||
- x64
|
||||
# - x32
|
||||
steps:
|
||||
|
||||
# Setup environment
|
||||
- uses: actions/checkout@v2
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: ${{ matrix.julia_version }}
|
||||
- name: Cache artifacts
|
||||
uses: actions/cache@v1
|
||||
env:
|
||||
cache-name: cache-artifacts
|
||||
with:
|
||||
path: ~/.julia/artifacts
|
||||
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-test-${{ env.cache-name }}-
|
||||
${{ runner.os }}-test-
|
||||
${{ runner.os }}-
|
||||
|
||||
# OS Dependencies
|
||||
# - name: Ubuntu OS dependencies
|
||||
# if: startsWith(matrix.os,'ubuntu')
|
||||
# run: |
|
||||
# ./test/install_wkhtmltoimage.sh
|
||||
|
||||
# at-spi2-core, libgtk-3-dev, libgtk-3-0, and xvfb are already installed: https://github.com/actions/virtual-environments/blob/master/images/linux/scripts/installers/basic.sh
|
||||
|
||||
|
||||
# TESTCMD
|
||||
- name: Default TESTCMD
|
||||
run: echo ::set-env name=TESTCMD::"julia"
|
||||
- name: Ubuntu TESTCMD
|
||||
if: startsWith(matrix.os,'ubuntu')
|
||||
run: echo ::set-env name=TESTCMD::"xvfb-run julia"
|
||||
|
||||
# Julia Deoendencies
|
||||
- name: Install Julia dependencies
|
||||
uses: julia-actions/julia-buildpkg@latest
|
||||
|
||||
# Run tests
|
||||
- name: Run Graphical test
|
||||
run: $TESTCMD --project -e 'using Pkg; Pkg.test(coverage=true);'
|
||||
|
||||
- name: Codecov
|
||||
uses: julia-actions/julia-uploadcodecov@latest
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
Skip:
|
||||
if: "contains(github.event.head_commit.message, '[skip ci]')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Skip CI 🚫
|
||||
run: echo skip ci
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
.DS_Store
|
||||
examples/.ipynb_checkpoints/*
|
||||
examples/meetup/.ipynb_checkpoints/*
|
||||
deps/plotly-latest.min.js
|
||||
deps/plotly-*
|
||||
deps/build.log
|
||||
deps/deps.jl
|
||||
Manifest.toml
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
# Documentation: http://docs.travis-ci.com/user/languages/julia/
|
||||
language: julia
|
||||
os:
|
||||
- linux
|
||||
# - osx
|
||||
julia:
|
||||
- 1.0
|
||||
- 1
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- julia: nightly
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- at-spi2-core
|
||||
- libgtk-3-dev
|
||||
- xauth
|
||||
- xvfb
|
||||
|
||||
env:
|
||||
- GKS_ENCODING="utf8"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.julia/artifacts
|
||||
|
||||
sudo: required
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pwd ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./test/install_wkhtmltoimage.sh ; fi
|
||||
|
||||
notifications:
|
||||
email: true
|
||||
|
||||
after_success:
|
||||
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
|
||||
|
||||
script:
|
||||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
||||
- if [[ `uname` = "Linux" ]]; then TESTCMD="xvfb-run julia"; else TESTCMD="julia"; fi
|
||||
- $TESTCMD -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)'
|
||||
+7
-10
@@ -1,7 +1,7 @@
|
||||
name = "Plots"
|
||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
author = ["Tom Breloff (@tbreloff)"]
|
||||
version = "1.1.2"
|
||||
version = "1.4.2"
|
||||
|
||||
[deps]
|
||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
@@ -15,7 +15,6 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
|
||||
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
|
||||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
||||
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
|
||||
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
|
||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||
@@ -35,25 +34,24 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||
Contour = "0.5"
|
||||
FFMPEG = "0.2, 0.3"
|
||||
FixedPointNumbers = "0.6, 0.7, 0.8"
|
||||
GR = "0.46, 0.47, 0.48"
|
||||
GR = "0.46, 0.47, 0.48, 0.49, 0.50"
|
||||
GeometryTypes = "0.7, 0.8"
|
||||
JSON = "0.21"
|
||||
Measures = "0.3"
|
||||
NaNMath = "0.3"
|
||||
PGFPlotsX = "1.2.0"
|
||||
PGFPlotsX = "1.2.0 - 1.2.6"
|
||||
PlotThemes = "2"
|
||||
PlotUtils = "1"
|
||||
RecipesBase = "1"
|
||||
RecipesPipeline = "0.1.3"
|
||||
RecipesPipeline = "0.1.7"
|
||||
Reexport = "0.2"
|
||||
Requires = "0.5, 1"
|
||||
Requires = "1"
|
||||
Showoff = "0.3.1"
|
||||
StatsBase = "0.32, 0.33"
|
||||
julia = "1"
|
||||
julia = "1.4"
|
||||
|
||||
[extras]
|
||||
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
|
||||
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
|
||||
Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44"
|
||||
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
|
||||
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
|
||||
@@ -62,7 +60,6 @@ LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
|
||||
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
|
||||
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
|
||||
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
|
||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
|
||||
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
|
||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||
@@ -70,4 +67,4 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
|
||||
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"
|
||||
|
||||
[targets]
|
||||
test = ["FileIO", "GeometryTypes", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "HDF5", "Random", "RDatasets", "StaticArrays", "StatsPlots", "Test", "UnicodePlots", "VisualRegressionTests"]
|
||||
test = ["FileIO", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "HDF5", "RDatasets", "StaticArrays", "StatsPlots", "Test", "UnicodePlots", "VisualRegressionTests"]
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# Plots
|
||||
|
||||
[travis-img]: https://img.shields.io/travis/JuliaPlots/Plots.jl?logo=travis
|
||||
[travis-url]: https://travis-ci.org/JuliaPlots/Plots.jl
|
||||
|
||||
[appveyor-img]: https://ci.appveyor.com/api/projects/status/github/juliaplots/plots.jl?branch=master&svg=true
|
||||
[appveyor-url]: https://ci.appveyor.com/project/mkborregaard/plots-jl
|
||||
[gh-ci-img]: https://github.com/JuliaPlots/Plots.jl/workflows/ci/badge.svg?branch=master
|
||||
[gh-ci-url]: https://github.com/JuliaPlots/Plots.jl/actions?query=workflow%3Aci
|
||||
|
||||
[pkgeval-img]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/P/Plots.svg
|
||||
[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html
|
||||
@@ -15,10 +12,9 @@
|
||||
[docs-img]: https://img.shields.io/badge/docs-stable-blue.svg
|
||||
[docs-url]: http://docs.juliaplots.org/latest/
|
||||
|
||||
[![][travis-img]][travis-url]
|
||||
[![][appveyor-img]][appveyor-url]
|
||||
[![][gh-ci-img]][gh-ci-url]
|
||||
[![][pkgeval-img]][pkgeval-url]
|
||||
[![][gitter-img]][gitter-url]
|
||||
[](https://julialang.zulipchat.com/#narrow/stream/236493-plots)
|
||||
[![][docs-img]][docs-url]
|
||||
[](https://codecov.io/gh/JuliaPlots/Plots.jl)
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
environment:
|
||||
matrix:
|
||||
- julia_version: 1.0
|
||||
- julia_version: 1
|
||||
- julia_version: nightly
|
||||
|
||||
platform:
|
||||
- x86 # 32-bit
|
||||
- x64 # 64-bit
|
||||
|
||||
# # Uncomment the following lines to allow failures on nightly julia
|
||||
# # (tests will run but not make your overall status red)
|
||||
matrix:
|
||||
allow_failures:
|
||||
- julia_version: nightly
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /release-.*/
|
||||
|
||||
cache:
|
||||
- '%USERPROFILE%\.julia\artifacts'
|
||||
|
||||
notifications:
|
||||
- provider: Email
|
||||
on_build_success: false
|
||||
on_build_failure: false
|
||||
on_build_status_changed: false
|
||||
|
||||
install:
|
||||
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
|
||||
|
||||
build_script:
|
||||
- echo "%JL_TEST_SCRIPT%"
|
||||
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
|
||||
|
||||
test_script:
|
||||
- echo "%JL_TEST_SCRIPT%"
|
||||
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
|
||||
|
||||
# # Uncomment to support code coverage upload. Should only be enabled for packages
|
||||
# # which would have coverage gaps without running on Windows
|
||||
# on_success:
|
||||
# - echo "%JL_CODECOV_SCRIPT%"
|
||||
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
|
||||
Vendored
+4
-4
@@ -1,12 +1,12 @@
|
||||
|
||||
#TODO: download https://cdn.plot.ly/plotly-latest.min.js to deps/ if it doesn't exist
|
||||
#TODO: download https://cdn.plot.ly/plotly-1.54.2.min.js to deps/ if it doesn't exist
|
||||
file_path = ""
|
||||
if get(ENV, "PLOTS_HOST_DEPENDENCY_LOCAL", "false") == "true"
|
||||
global file_path
|
||||
local_fn = joinpath(dirname(@__FILE__), "plotly-latest.min.js")
|
||||
local_fn = joinpath(dirname(@__FILE__), "plotly-1.54.2.min.js")
|
||||
if !isfile(local_fn)
|
||||
@info("Cannot find deps/plotly-latest.min.js... downloading latest version.")
|
||||
download("https://cdn.plot.ly/plotly-latest.min.js", local_fn)
|
||||
@info("Cannot find deps/plotly-1.54.2.min.js... downloading latest version.")
|
||||
download("https://cdn.plot.ly/plotly-1.54.2.min.js", local_fn)
|
||||
isfile(local_fn) && (file_path = local_fn)
|
||||
else
|
||||
file_path = local_fn
|
||||
|
||||
+7
-2
@@ -10,7 +10,7 @@ using Reexport
|
||||
|
||||
import GeometryTypes
|
||||
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
|
||||
import SparseArrays: findnz
|
||||
import SparseArrays: AbstractSparseMatrix, findnz
|
||||
|
||||
using FFMPEG
|
||||
|
||||
@@ -108,6 +108,7 @@ export
|
||||
gif,
|
||||
mov,
|
||||
mp4,
|
||||
webm,
|
||||
animate,
|
||||
@animate,
|
||||
@gif,
|
||||
@@ -123,7 +124,11 @@ export
|
||||
center,
|
||||
BezierCurve,
|
||||
|
||||
plotattr
|
||||
plotattr,
|
||||
scalefontsize,
|
||||
scalefontsizes,
|
||||
resetfontsizes
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
||||
|
||||
+4
-2
@@ -24,6 +24,7 @@ end
|
||||
giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif")
|
||||
movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov")
|
||||
mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4")
|
||||
webmfn() = (isijulia() ? "tmp.webm" : tempname()*".webm")
|
||||
|
||||
mutable struct FrameIterator
|
||||
itr
|
||||
@@ -63,6 +64,7 @@ file_extension(fn) = Base.Filesystem.splitext(fn)[2][2:end]
|
||||
gif(anim::Animation, fn = giffn(); kw...) = buildanimation(anim, fn; kw...)
|
||||
mov(anim::Animation, fn = movfn(); kw...) = buildanimation(anim, fn, false; kw...)
|
||||
mp4(anim::Animation, fn = mp4fn(); kw...) = buildanimation(anim, fn, false; kw...)
|
||||
webm(anim::Animation, fn = webmfn(); kw...) = buildanimation(anim, fn, false; kw...)
|
||||
|
||||
ffmpeg_framerate(fps) = "$fps"
|
||||
ffmpeg_framerate(fps::Rational) = "$(fps.num)/$(fps.den)"
|
||||
@@ -110,8 +112,8 @@ function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif)
|
||||
ext = file_extension(agif.filename)
|
||||
if ext == "gif"
|
||||
html = "<img src=\"data:image/gif;base64," * base64encode(read(agif.filename)) * "\" />"
|
||||
elseif ext in ("mov", "mp4")
|
||||
mimetype = ext == "mov" ? "video/quicktime" : "video/mp4"
|
||||
elseif ext in ("mov", "mp4","webm")
|
||||
mimetype = ext == "mov" ? "video/quicktime" : "video/$ext"
|
||||
html = "<video controls><source src=\"data:$mimetype;base64," *
|
||||
base64encode(read(agif.filename)) *
|
||||
"\" type = \"$mimetype\"></video>"
|
||||
|
||||
+4
-3
@@ -70,7 +70,7 @@ const _arg_desc = KW(
|
||||
:dpi => "Number. Dots Per Inch of output figures",
|
||||
:thickness_scaling => "Number. Scale for the thickness of all line elements like lines, borders, axes, grid lines, ... defaults to 1.",
|
||||
:display_type => "Symbol (`:auto`, `:gui`, or `:inline`). When supported, `display` will either open a GUI window or plot inline.",
|
||||
:extra_kwargs => "KW (Dict{Symbol,Any}). Pass a map of extra keyword args which may be specific to a backend.",
|
||||
:extra_kwargs => "Either one of (`:plot`, `:subplot`, `:series`) to specify for which element extra keyword args are collected or a KW (Dict{Symbol,Any}) to pass a map of extra keyword args which may be specific to a backend. Default: `:series`.\n Example: `pgfplotsx(); scatter(1:5, extra_kwargs=Dict(:subplot=>Dict(\"axis line shift\" => \"10pt\"))`",
|
||||
:fontfamily => "String or Symbol. Default font family for title, legend entries, tick labels and guides",
|
||||
:warn_on_unsupported => "Bool. Warn on unsupported attributes, series types and marker shapes",
|
||||
|
||||
@@ -90,13 +90,14 @@ const _arg_desc = KW(
|
||||
:foreground_color_legend => "Color Type or `:match` (matches `:foreground_color_subplot`). Foreground color of the legend.",
|
||||
:foreground_color_title => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of subplot title.",
|
||||
:color_palette => "Vector of colors (cycle through) or color gradient (generate list from gradient) or `:auto` (generate a color list using `Colors.distiguishable_colors` and custom seed colors chosen to contrast with the background). The color palette is a color list from which series colors are automatically chosen.",
|
||||
:legend => "Bool (show the legend?) or (x,y) tuple or Symbol (legend position). Bottom left corner of legend is placed at (x,y). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:inside`, `:legend`, `:topright`, `:topleft`, `:bottomleft`, `:bottomright` , `:inline` (note: only some may be supported in each backend)",
|
||||
:legend => "Bool (show the legend?) or (x,y) tuple or Symbol (legend position). Bottom left corner of legend is placed at (x,y). Symbol values: `:none`; `:best`; `:inline`; `:inside`; `:legend`; any valid combination of `:(outer ?)(top/bottom ?)(right/left ?)`, i.e.: `:top`, `:topright`, `:outerleft`, `:outerbottomright` ... (note: only some may be supported in each backend)",
|
||||
:legendfontfamily => "String or Symbol. Font family of legend entries.",
|
||||
:legendfontsize => "Integer. Font pointsize of legend entries.",
|
||||
:legendfonthalign => "Symbol. Font horizontal alignment of legend entries: :hcenter, :left, :right or :center",
|
||||
:legendfontvalign => "Symbol. Font vertical alignment of legend entries: :vcenter, :top, :bottom or :center",
|
||||
:legendfontrotation => "Real. Font rotation of legend entries",
|
||||
:legendfontcolor => "Color Type. Font color of legend entries",
|
||||
:legendtitle => "String. Legend title.",
|
||||
:legendtitlefontfamily => "String or Symbol. Font family of the legend title.",
|
||||
:legendtitlefontsize => "Integer. Font pointsize the legend title.",
|
||||
:legendtitlefonthalign => "Symbol. Font horizontal alignment of the legend title: :hcenter, :left, :right or :center",
|
||||
@@ -104,7 +105,7 @@ const _arg_desc = KW(
|
||||
:legendtitlefontrotation => "Real. Font rotation of the legend title",
|
||||
:legendtitlefontcolor => "Color Type. Font color of the legend title",
|
||||
:colorbar => "Bool (show the colorbar?) or Symbol (colorbar position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:legend` (matches legend value) (note: only some may be supported in each backend)",
|
||||
:clims => "`:auto` or NTuple{2,Number}. Fixes the limits of the colorbar.",
|
||||
:clims => "`:auto`, NTuple{2,Number}, or a function that takes series data in and returns NTuple{2,Number}. Fixes the limits of the colorbar.",
|
||||
:legendfont => "Font. Font of legend items.",
|
||||
:legendtitlefont => "Font. Font of the legend title.",
|
||||
:annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String or PlotText (created with `text(args...)`) Add one-off text annotations at the x,y coordinates.",
|
||||
|
||||
+34
-12
@@ -20,7 +20,14 @@ function add_non_underscore_aliases!(aliases::Dict{Symbol,Symbol})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function add_non_underscore_aliases!(aliases::Dict{Symbol,Symbol}, args::Vector{Symbol})
|
||||
for arg in args
|
||||
s = string(arg)
|
||||
if '_' in s
|
||||
aliases[Symbol(replace(s, "_" => ""))] = arg
|
||||
end
|
||||
end
|
||||
end
|
||||
# ------------------------------------------------------------
|
||||
|
||||
const _allAxes = [:auto, :left, :right]
|
||||
@@ -281,6 +288,7 @@ const _series_defaults = KW(
|
||||
# one logical series to be broken up (path and markers, for example)
|
||||
:hover => nothing, # text to display when hovering over the data points
|
||||
:stride => (1,1), # array stride for wireframe/surface, the first element is the row stride and the second is the column stride.
|
||||
:extra_kwargs => Dict()
|
||||
)
|
||||
|
||||
|
||||
@@ -292,7 +300,7 @@ const _plot_defaults = KW(
|
||||
:fontfamily => "sans-serif",
|
||||
:size => (600,400),
|
||||
:pos => (0,0),
|
||||
:window_title => "Plots.jl",
|
||||
:window_title => "Plots.jl",
|
||||
:show => false,
|
||||
:layout => 1,
|
||||
:link => :none,
|
||||
@@ -304,8 +312,9 @@ const _plot_defaults = KW(
|
||||
:dpi => DPI, # dots per inch for images, etc
|
||||
:thickness_scaling => 1,
|
||||
:display_type => :auto,
|
||||
:extra_kwargs => KW(),
|
||||
:warn_on_unsupported => true,
|
||||
:extra_plot_kwargs => Dict(),
|
||||
:extra_kwargs => :series, # directs collection of extra_kwargs
|
||||
)
|
||||
|
||||
|
||||
@@ -354,6 +363,7 @@ const _subplot_defaults = KW(
|
||||
:colorbar_title => "",
|
||||
:framestyle => :axes,
|
||||
:camera => (30,30),
|
||||
:extra_kwargs => Dict()
|
||||
)
|
||||
|
||||
const _axis_defaults = KW(
|
||||
@@ -499,6 +509,13 @@ end
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# margin
|
||||
add_aliases(:left_margin , :leftmargin )
|
||||
add_aliases(:top_margin , :topmargin)
|
||||
add_aliases(:bottom_margin , :bottommargin)
|
||||
add_aliases(:right_margin ,:rightmargin)
|
||||
|
||||
|
||||
# colors
|
||||
add_aliases(:seriescolor, :c, :color, :colour)
|
||||
add_aliases(:linecolor, :lc, :lcolor, :lcolour, :linecolour)
|
||||
@@ -580,6 +597,7 @@ add_aliases(:fill_z, :fillz, :fz, :surfacecolor, :surfacecolour, :sc, :surfcolor
|
||||
add_aliases(:legend, :leg, :key)
|
||||
add_aliases(:legendtitle, :legend_title, :labeltitle, :label_title, :leg_title, :key_title)
|
||||
add_aliases(:colorbar, :cb, :cbar, :colorkey)
|
||||
add_aliases(:colorbar_title, :colorbartitle, :cb_title, :cbtitle, :cbartitle, :cbar_title, :colorkeytitle, :colorkey_title)
|
||||
add_aliases(:clims, :clim, :cbarlims, :cbar_lims, :climits, :color_limits)
|
||||
add_aliases(:smooth, :regression, :reg)
|
||||
add_aliases(:levels, :nlevels, :nlev, :levs)
|
||||
@@ -619,7 +637,7 @@ for arg in keys(_series_defaults)
|
||||
_keyAliases[makeplural(arg)] = arg
|
||||
end
|
||||
|
||||
|
||||
add_non_underscore_aliases!(_keyAliases)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -656,7 +674,7 @@ function default(k::Symbol)
|
||||
return _axis_defaults_byletter[letter][key]
|
||||
end
|
||||
k == :letter && return k # for type recipe processing
|
||||
k in _suppress_warnings || error("Unknown key: ", k)
|
||||
return missing
|
||||
end
|
||||
|
||||
function default(k::Symbol, v)
|
||||
@@ -941,8 +959,9 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
||||
replaceAliases!(plotattributes, _keyAliases)
|
||||
|
||||
# handle axis args common to all axis
|
||||
args = RecipesPipeline.pop_kw!(plotattributes, :axis, ())
|
||||
for arg in wraptuple(args)
|
||||
args = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :axis, ()))
|
||||
showarg = wraptuple(RecipesPipeline.pop_kw!(plotattributes, :showaxis, ()))
|
||||
for arg in wraptuple((args..., showarg...))
|
||||
for letter in (:x, :y, :z)
|
||||
process_axis_arg!(plotattributes, arg, letter)
|
||||
end
|
||||
@@ -1121,26 +1140,29 @@ const _already_warned = Dict{Symbol,Set{Symbol}}()
|
||||
const _to_warn = Set{Symbol}()
|
||||
|
||||
function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
|
||||
if !get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported])
|
||||
return
|
||||
end
|
||||
empty!(_to_warn)
|
||||
bend = backend_name(pkg)
|
||||
already_warned = get!(_already_warned, bend, Set{Symbol}())
|
||||
extra_kwargs = Dict{Symbol,Any}()
|
||||
for k in keys(plotattributes)
|
||||
is_attr_supported(pkg, k) && continue
|
||||
k in _suppress_warnings && continue
|
||||
if plotattributes[k] != default(k)
|
||||
default_value = default(k)
|
||||
if ismissing(default_value)
|
||||
extra_kwargs[k] = pop_kw!(plotattributes, k)
|
||||
elseif plotattributes[k] != default(k)
|
||||
k in already_warned || push!(_to_warn, k)
|
||||
end
|
||||
end
|
||||
|
||||
if !isempty(_to_warn)
|
||||
if !isempty(_to_warn) &&
|
||||
!get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported])
|
||||
for k in sort(collect(_to_warn))
|
||||
push!(already_warned, k)
|
||||
@warn("Keyword argument $k not supported with $pkg. Choose from: $(supported_attrs(pkg))")
|
||||
end
|
||||
end
|
||||
return extra_kwargs
|
||||
end
|
||||
|
||||
# _markershape_supported(pkg::AbstractBackend, shape::Symbol) = shape in supported_markers(pkg)
|
||||
|
||||
+4
-23
@@ -35,7 +35,6 @@ end
|
||||
function process_axis_arg!(plotattributes::AKW, arg, letter = "")
|
||||
T = typeof(arg)
|
||||
arg = get(_scaleAliases, arg, arg)
|
||||
|
||||
if typeof(arg) <: Font
|
||||
plotattributes[Symbol(letter,:tickfont)] = arg
|
||||
plotattributes[Symbol(letter,:guidefont)] = arg
|
||||
@@ -182,16 +181,10 @@ function optimal_ticks_and_labels(sp::Subplot, axis::Axis, ticks = nothing)
|
||||
|
||||
labels = if any(isfinite, unscaled_ticks)
|
||||
formatter = axis[:formatter]
|
||||
if formatter == :auto
|
||||
# the default behavior is to make strings of the scaled values and then apply the labelfunc
|
||||
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :auto))
|
||||
elseif formatter == :plain
|
||||
# Leave the numbers in plain format
|
||||
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :plain))
|
||||
elseif formatter == :scientific
|
||||
Showoff.showoff(unscaled_ticks, :scientific)
|
||||
elseif formatter == :latex
|
||||
map(x -> string("\$", replace(convert_sci_unicode(x), '×' => "\\times"), "\$"), Showoff.showoff(unscaled_ticks, :auto))
|
||||
if formatter in (:auto, :plain, :scientific, :engineering)
|
||||
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, formatter))
|
||||
elseif formatter == :latex
|
||||
map(x -> string("\$", replace(convert_sci_unicode(x), '×' => "\\times"), "\$"), Showoff.showoff(unscaled_ticks, :auto))
|
||||
else
|
||||
# there was an override for the formatter... use that on the unscaled ticks
|
||||
map(formatter, unscaled_ticks)
|
||||
@@ -576,18 +569,6 @@ end
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
function pie_labels(sp::Subplot, series::Series)
|
||||
plotattributes = series.plotattributes
|
||||
if haskey(plotattributes,:x_discrete_indices)
|
||||
dvals = sp.attr[:xaxis].plotattributes[:discrete_values]
|
||||
[dvals[idx] for idx in plotattributes[:x_discrete_indices]]
|
||||
else
|
||||
plotattributes[:x]
|
||||
end
|
||||
end
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# compute the line segments which should be drawn for this axis
|
||||
function axis_drawing_info(sp::Subplot)
|
||||
xaxis, yaxis = sp[:xaxis], sp[:yaxis]
|
||||
|
||||
+62
-23
@@ -1,5 +1,3 @@
|
||||
using Pkg
|
||||
|
||||
struct NoBackend <: AbstractBackend end
|
||||
|
||||
const _backendType = Dict{Symbol, DataType}(:none => NoBackend)
|
||||
@@ -190,11 +188,15 @@ function backend(sym::Symbol)
|
||||
end
|
||||
end
|
||||
|
||||
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse, :glvisualize]
|
||||
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse, :glvisualize, :pgfplots]
|
||||
|
||||
function warn_on_deprecated_backend(bsym::Symbol)
|
||||
if bsym in _deprecated_backends
|
||||
@warn("Backend $bsym has been deprecated.")
|
||||
if bsym == :pgfplots
|
||||
@warn("Backend $bsym has been deprecated. Use pgfplotsx instead.")
|
||||
else
|
||||
@warn("Backend $bsym has been deprecated.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -341,10 +343,18 @@ const _gr_attr = merge_with_base_supported([
|
||||
:contour_labels,
|
||||
])
|
||||
const _gr_seriestype = [
|
||||
:path, :scatter, :straightline,
|
||||
:heatmap, :pie, :image,
|
||||
:contour, :path3d, :scatter3d, :surface, :wireframe, :volume,
|
||||
:shape
|
||||
:path,
|
||||
:scatter,
|
||||
:straightline,
|
||||
:heatmap,
|
||||
:image,
|
||||
:contour,
|
||||
:path3d,
|
||||
:scatter3d,
|
||||
:surface,
|
||||
:wireframe,
|
||||
:volume,
|
||||
:shape,
|
||||
]
|
||||
const _gr_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
const _gr_marker = _allMarkers
|
||||
@@ -408,9 +418,17 @@ const _plotly_attr = merge_with_base_supported([
|
||||
])
|
||||
|
||||
const _plotly_seriestype = [
|
||||
:path, :scatter, :pie, :heatmap,
|
||||
:contour, :surface, :wireframe, :path3d, :scatter3d, :shape, :scattergl,
|
||||
:straightline
|
||||
:path,
|
||||
:scatter,
|
||||
:heatmap,
|
||||
:contour,
|
||||
:surface,
|
||||
:wireframe,
|
||||
:path3d,
|
||||
:scatter3d,
|
||||
:shape,
|
||||
:scattergl,
|
||||
:straightline,
|
||||
]
|
||||
const _plotly_style = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
const _plotly_marker = [
|
||||
@@ -533,12 +551,22 @@ const _pyplot_attr = merge_with_base_supported([
|
||||
:contour_labels,
|
||||
])
|
||||
const _pyplot_seriestype = [
|
||||
:path, :steppre, :steppost, :shape, :straightline,
|
||||
:scatter, :hexbin, #:histogram2d, :histogram,
|
||||
# :bar,
|
||||
:heatmap, :pie, :image,
|
||||
:contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
|
||||
]
|
||||
:path,
|
||||
:steppre,
|
||||
:steppost,
|
||||
:shape,
|
||||
:straightline,
|
||||
:scatter,
|
||||
:hexbin,
|
||||
:heatmap,
|
||||
:image,
|
||||
:contour,
|
||||
:contour3d,
|
||||
:path3d,
|
||||
:scatter3d,
|
||||
:surface,
|
||||
:wireframe,
|
||||
]
|
||||
const _pyplot_style = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
const _pyplot_marker = vcat(_allMarkers, :pixel)
|
||||
const _pyplot_scale = [:identity, :ln, :log2, :log10]
|
||||
@@ -605,12 +633,22 @@ const _hdf5_attr = merge_with_base_supported([
|
||||
:colorbar_title,
|
||||
])
|
||||
const _hdf5_seriestype = [
|
||||
:path, :steppre, :steppost, :shape, :straightline,
|
||||
:scatter, :hexbin, #:histogram2d, :histogram,
|
||||
# :bar,
|
||||
:heatmap, :pie, :image,
|
||||
:contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
|
||||
]
|
||||
:path,
|
||||
:steppre,
|
||||
:steppost,
|
||||
:shape,
|
||||
:straightline,
|
||||
:scatter,
|
||||
:hexbin,
|
||||
:heatmap,
|
||||
:image,
|
||||
:contour,
|
||||
:contour3d,
|
||||
:path3d,
|
||||
:scatter3d,
|
||||
:surface,
|
||||
:wireframe,
|
||||
]
|
||||
const _hdf5_style = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
const _hdf5_marker = vcat(_allMarkers, :pixel)
|
||||
const _hdf5_scale = [:identity, :ln, :log2, :log10]
|
||||
@@ -792,6 +830,7 @@ const _pgfplotsx_seriestype = [
|
||||
:heatmap,
|
||||
:contour,
|
||||
:contour3d,
|
||||
:quiver,
|
||||
:shape,
|
||||
:steppre,
|
||||
:stepmid,
|
||||
|
||||
+275
-242
File diff suppressed because it is too large
Load Diff
@@ -437,7 +437,7 @@ end
|
||||
|
||||
function _show(io::IO, mime::MIME{Symbol("image/png")}, plt::Plot{InspectDRBackend})
|
||||
dpi = plt[:dpi] # TODO: support
|
||||
_inspectdr_show(io, "image/png", _inspectdr_getmplot(plt.o), plt[:size]...)
|
||||
_inspectdr_show(io, mime, _inspectdr_getmplot(plt.o), plt[:size]...)
|
||||
end
|
||||
for (mime, fmt) in (
|
||||
"image/svg+xml" => "svg",
|
||||
|
||||
+129
-76
@@ -86,7 +86,16 @@ end
|
||||
function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
if !pgfx_plot.is_created || pgfx_plot.was_shown
|
||||
pgfx_sanitize_plot!(plt)
|
||||
the_plot = PGFPlotsX.TikzPicture(PGFPlotsX.Options())
|
||||
# extract extra kwargs
|
||||
extra_plot_opt = plt[:extra_plot_kwargs]
|
||||
extra_plot = nothing
|
||||
if haskey(extra_plot_opt, :add)
|
||||
extra_plot = wraptuple(pop!(extra_plot_opt,:add))
|
||||
end
|
||||
the_plot = PGFPlotsX.TikzPicture(PGFPlotsX.Options(extra_plot_opt...))
|
||||
if extra_plot !== nothing
|
||||
push!(the_plot, extra_plot...)
|
||||
end
|
||||
bgc = plt.attr[:background_color_outside] == :match ?
|
||||
plt.attr[:background_color] : plt.attr[:background_color_outside]
|
||||
if bgc isa Colors.Colorant
|
||||
@@ -127,17 +136,12 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
bgc_inside = plot_color(sp[:background_color_inside])
|
||||
bgc_inside_a = alpha(bgc_inside)
|
||||
axis_opt = PGFPlotsX.Options(
|
||||
"point meta max" => get_clims(sp)[2],
|
||||
"point meta min" => get_clims(sp)[1],
|
||||
"legend cell align" => "left",
|
||||
"title" => sp[:title],
|
||||
"title style" => PGFPlotsX.Options(
|
||||
"at" => if title_loc == :left
|
||||
"{(0,1)}"
|
||||
elseif title_loc == :right
|
||||
"{(1,1)}"
|
||||
elseif title_loc isa Tuple
|
||||
"{$(string(title_loc))}"
|
||||
else
|
||||
"{(0.5,1)}"
|
||||
end,
|
||||
pgfx_get_title_pos(title_loc)...,
|
||||
"font" => pgfx_font(
|
||||
sp[:titlefontsize],
|
||||
pgfx_thickness_scaling(sp),
|
||||
@@ -175,12 +179,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) :
|
||||
nothing
|
||||
# legend position
|
||||
if sp[:legend] isa Tuple
|
||||
x, y = sp[:legend]
|
||||
push!(axis_opt["legend style"], "at={($x, $y)}")
|
||||
else
|
||||
push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
|
||||
end
|
||||
push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
|
||||
for letter in (:x, :y, :z)
|
||||
if letter != :z || RecipesPipeline.is3d(sp)
|
||||
pgfx_axis!(axis_opt, sp, letter)
|
||||
@@ -197,41 +196,48 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
# As it is likely that all series within the same axis use the same
|
||||
# colormap this should not cause any problem.
|
||||
for series in series_list(sp)
|
||||
if hascolorbar(series)
|
||||
cg = get_colorgradient(series)
|
||||
cm = pgfx_colormap(get_colorgradient(series))
|
||||
PGFPlotsX.push_preamble!(
|
||||
pgfx_plot.the_plot,
|
||||
"""\\pgfplotsset{
|
||||
colormap={plots$(sp.attr[:subplot_index])}{$cm},
|
||||
}""",
|
||||
)
|
||||
if hascolorbar(series)
|
||||
cg = get_colorgradient(series)
|
||||
cm = pgfx_colormap(get_colorgradient(series))
|
||||
PGFPlotsX.push_preamble!(
|
||||
pgfx_plot.the_plot,
|
||||
"""\\pgfplotsset{
|
||||
colormap={plots$(sp.attr[:subplot_index])}{$cm},
|
||||
}""",
|
||||
)
|
||||
push!(axis_opt, "colormap name" => "plots$(sp.attr[:subplot_index])")
|
||||
if cg isa PlotUtils.CategoricalColorGradient
|
||||
push!(
|
||||
axis_opt,
|
||||
"colorbar" => nothing,
|
||||
"colormap name" => "plots$(sp.attr[:subplot_index])",
|
||||
"colormap access" => "piecewise const",
|
||||
"colorbar sampled" => nothing,
|
||||
)
|
||||
if cg isa PlotUtils.CategoricalColorGradient
|
||||
push!(
|
||||
axis_opt,
|
||||
"colormap access" => "piecewise const",
|
||||
"colorbar sampled" => nothing,
|
||||
)
|
||||
end
|
||||
# goto is needed to break out of col and series for
|
||||
@goto colorbar_end
|
||||
end
|
||||
# goto is needed to break out of col and series for
|
||||
@goto colorbar_end
|
||||
end
|
||||
end
|
||||
@label colorbar_end
|
||||
|
||||
push!(
|
||||
axis_opt,
|
||||
"colorbar style" => PGFPlotsX.Options(
|
||||
if hascolorbar(sp)
|
||||
colorbar_style = PGFPlotsX.Options(
|
||||
"title" => sp[:colorbar_title],
|
||||
),
|
||||
"point meta max" => get_clims(sp)[2],
|
||||
"point meta min" => get_clims(sp)[1],
|
||||
)
|
||||
"xticklabel style" => pgfx_get_ticklabel_style(sp, sp[:xaxis]),
|
||||
"yticklabel style" => pgfx_get_ticklabel_style(sp, sp[:yaxis]),
|
||||
)
|
||||
if sp[:colorbar] === :top
|
||||
push!(colorbar_style,
|
||||
"at" => string((0.5, 1.05)),
|
||||
"anchor" => "south",
|
||||
"xticklabel pos" => "upper",
|
||||
)
|
||||
end
|
||||
push!(
|
||||
axis_opt,
|
||||
string("colorbar", pgfx_get_colorbar_pos(sp[:colorbar])) => nothing,
|
||||
"colorbar style" => colorbar_style,
|
||||
)
|
||||
end
|
||||
if RecipesPipeline.is3d(sp)
|
||||
azim, elev = sp[:camera]
|
||||
push!(axis_opt, "view" => (azim, elev))
|
||||
@@ -243,7 +249,15 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
else
|
||||
PGFPlotsX.Axis
|
||||
end
|
||||
axis = axisf(axis_opt)
|
||||
extra_sp_opt = sp[:extra_kwargs]
|
||||
extra_sp = nothing
|
||||
if haskey(extra_sp_opt, :add)
|
||||
extra_sp = wraptuple(pop!(extra_sp_opt,:add))
|
||||
end
|
||||
axis = axisf(merge(axis_opt, PGFPlotsX.Options(extra_sp_opt...)))
|
||||
if extra_sp !== nothing
|
||||
push!(axis, extra_sp...)
|
||||
end
|
||||
if sp[:legendtitle] !== nothing
|
||||
push!(axis, PGFPlotsX.Options("\\addlegendimage{empty legend}" => nothing))
|
||||
push!(
|
||||
@@ -265,7 +279,13 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
"color" => single_color(opt[:linecolor]),
|
||||
"name path" => string(series_id),
|
||||
)
|
||||
if RecipesPipeline.is3d(series) || st == :heatmap
|
||||
extra_series_opt = series[:extra_kwargs]
|
||||
extra_series = nothing
|
||||
if haskey(extra_series_opt, :add)
|
||||
extra_series = wraptuple(pop!(extra_series_opt,:add))
|
||||
end
|
||||
series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...))
|
||||
if RecipesPipeline.is3d(series) || st in (:heatmap, :contour)
|
||||
series_func = PGFPlotsX.Plot3
|
||||
else
|
||||
series_func = PGFPlotsX.Plot
|
||||
@@ -274,7 +294,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
!isfilledcontour(series) && series[:ribbon] === nothing
|
||||
push!(series_opt, "area legend" => nothing)
|
||||
end
|
||||
if st == :heatmap
|
||||
if st in (:heatmap, :contour)
|
||||
push!(axis.options, "view" => "{0}{90}")
|
||||
end
|
||||
# treat segments
|
||||
@@ -319,12 +339,13 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
end
|
||||
segment_opt = merge(segment_opt, pgfx_marker(opt, i))
|
||||
end
|
||||
if st == :shape || isfilledcontour(series)
|
||||
if st == :shape
|
||||
segment_opt = merge(segment_opt, pgfx_fillstyle(opt, i))
|
||||
end
|
||||
# add fillrange
|
||||
if sf !== nothing &&
|
||||
!isfilledcontour(series) && series[:ribbon] === nothing
|
||||
!isfilledcontour(series) &&
|
||||
series[:ribbon] === nothing
|
||||
if sf isa Number || sf isa AVec
|
||||
pgfx_fillrange_series!(
|
||||
axis,
|
||||
@@ -344,6 +365,9 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
pgfx_series_coordinates!(sp, series, segment_opt, opt, rng)
|
||||
segment_plot =
|
||||
series_func(merge(series_opt, segment_opt), coordinates)
|
||||
if extra_series !== nothing
|
||||
push!(segment_plot, extra_series...)
|
||||
end
|
||||
push!(axis, segment_plot)
|
||||
# fill between functions
|
||||
if sf isa Tuple && series[:ribbon] === nothing
|
||||
@@ -570,8 +594,8 @@ function pgfx_series_coordinates!(
|
||||
xs, ys, zs = collect(args)
|
||||
push!(
|
||||
segment_opt,
|
||||
"contour filled" => PGFPlotsX.Options("labels" => opt[:contour_labels]),
|
||||
"point meta" => "explicit",
|
||||
"contour filled" => PGFPlotsX.Options(), # labels not supported
|
||||
"patch type" => "bilinear",
|
||||
"shader" => "flat",
|
||||
)
|
||||
if opt[:levels] isa Number
|
||||
@@ -580,17 +604,7 @@ function pgfx_series_coordinates!(
|
||||
push!(segment_opt["contour filled"], "levels" => opt[:levels])
|
||||
end
|
||||
|
||||
cs = join(
|
||||
[
|
||||
join(["($x, $y) [$(zs[j, i])]" for (j, x) in enumerate(xs)], " ") for (i, y) in enumerate(ys)
|
||||
],
|
||||
"\n\n",
|
||||
)
|
||||
"""
|
||||
coordinates {
|
||||
$cs
|
||||
};
|
||||
"""
|
||||
PGFPlotsX.Coordinates(args...)
|
||||
end
|
||||
##
|
||||
pgfx_get_linestyle(k) = get(
|
||||
@@ -629,6 +643,26 @@ pgfx_get_marker(k) = get(
|
||||
"*",
|
||||
)
|
||||
|
||||
pgfx_get_xguide_pos(k) = get(
|
||||
(
|
||||
top = "at={(0.5,1)},above,",
|
||||
right = "at={(ticklabel* cs:1.02)}, anchor=west,",
|
||||
left = "at={(ticklabel* cs:-0.02)}, anchor=east,",
|
||||
),
|
||||
k,
|
||||
"at={(ticklabel cs:0.5)}, anchor=near ticklabel"
|
||||
)
|
||||
|
||||
pgfx_get_yguide_pos(k) = get(
|
||||
(
|
||||
top = "at={(ticklabel* cs:1.02)}, anchor=south",
|
||||
right = "at={(1,0.5)},below,",
|
||||
bottom = "at={(ticklabel* cs:-0.02)}, anchor=north,",
|
||||
),
|
||||
k,
|
||||
"at={(ticklabel cs:0.5)}, anchor=near ticklabel"
|
||||
)
|
||||
|
||||
pgfx_get_legend_pos(k) = get(
|
||||
(
|
||||
top = ("at" => string((0.5, 0.98)), "anchor" => "north"),
|
||||
@@ -651,6 +685,33 @@ pgfx_get_legend_pos(k) = get(
|
||||
Symbol(k),
|
||||
("at" => string((1.02, 1)), "anchor" => "north west"),
|
||||
)
|
||||
pgfx_get_legend_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "north west")
|
||||
pgfx_get_legend_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor))
|
||||
|
||||
pgfx_get_colorbar_pos(s) =
|
||||
get((left = " left", bottom = " horizontal", top = " horizontal"), s, "")
|
||||
pgfx_get_colorbar_pos(b::Bool) = ""
|
||||
|
||||
pgfx_get_title_pos(s) =
|
||||
get((
|
||||
left = ("at" => "{(0,1)}", "anchor" => "south west"),
|
||||
right = ("at" => "{(1,1)}", "anchor" => "south east"),
|
||||
), s,
|
||||
("at" => "{(0.5,1)}", "anchor" => "south"))
|
||||
pgfx_get_title_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "south")
|
||||
pgfx_get_title_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor))
|
||||
|
||||
function pgfx_get_ticklabel_style(sp, axis)
|
||||
cstr = plot_color(axis[:tickfontcolor])
|
||||
return PGFPlotsX.Options(
|
||||
"font" => pgfx_font(
|
||||
axis[:tickfontsize], pgfx_thickness_scaling(sp)
|
||||
),
|
||||
"color" => cstr,
|
||||
"draw opacity" => alpha(cstr),
|
||||
"rotate" => axis[:tickfontrotation],
|
||||
)
|
||||
end
|
||||
|
||||
## --------------------------------------------------------------------------------------
|
||||
# Generates a colormap for pgfplots based on a ColorGradient
|
||||
@@ -757,7 +818,6 @@ function pgfx_should_add_to_legend(series::Series)
|
||||
:contourf,
|
||||
:contour3d,
|
||||
:heatmap,
|
||||
:pie,
|
||||
:image,
|
||||
)
|
||||
)
|
||||
@@ -928,6 +988,7 @@ end
|
||||
function pgfx_sanitize_string(s::LaTeXString)
|
||||
s = replace(s, r"\\?\#" => "\\#")
|
||||
s = replace(s, r"\\?\%" => "\\%")
|
||||
return LaTeXString(s)
|
||||
end
|
||||
end
|
||||
function pgfx_sanitize_plot!(plt)
|
||||
@@ -993,10 +1054,10 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
|
||||
# axis label position
|
||||
labelpos = ""
|
||||
if letter == :x && axis[:guide_position] == :top
|
||||
labelpos = "at={(0.5,1)},above,"
|
||||
elseif letter == :y && axis[:guide_position] == :right
|
||||
labelpos = "at={(1,0.5)},below,"
|
||||
if letter == :x
|
||||
labelpos = pgfx_get_xguide_pos(axis[:guide_position])
|
||||
elseif letter == :y
|
||||
labelpos = pgfx_get_yguide_pos(axis[:guide_position])
|
||||
end
|
||||
|
||||
# Add label font
|
||||
@@ -1089,17 +1150,8 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
string(letter, "tick align") =>
|
||||
(axis[:tick_direction] == :out ? "outside" : "inside"),
|
||||
)
|
||||
cstr = plot_color(axis[:tickfontcolor])
|
||||
α = alpha(cstr)
|
||||
push!(
|
||||
opt,
|
||||
string(letter, "ticklabel style") => PGFPlotsX.Options(
|
||||
"font" =>
|
||||
pgfx_font(axis[:tickfontsize], pgfx_thickness_scaling(sp)),
|
||||
"color" => cstr,
|
||||
"draw opacity" => α,
|
||||
"rotate" => axis[:tickfontrotation],
|
||||
),
|
||||
opt, string(letter, "ticklabel style") => pgfx_get_ticklabel_style(sp, axis)
|
||||
)
|
||||
push!(
|
||||
opt,
|
||||
@@ -1187,6 +1239,7 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# --------------------------------------------------------------------------------------
|
||||
# display calls this and then _display, its called 3 times for plot(1:5)
|
||||
# Set the (left, top, right, bottom) minimum padding around the plot area
|
||||
|
||||
+53
-38
@@ -20,22 +20,6 @@ using UUIDs
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
plotly_legend_pos(pos::Symbol) = get(
|
||||
(
|
||||
right = [1.0, 0.5],
|
||||
left = [0.0, 0.5],
|
||||
top = [0.5, 1.0],
|
||||
bottom = [0.5, 0.0],
|
||||
bottomleft = [0.0, 0.0],
|
||||
bottomright = [1.0, 0.0],
|
||||
topright = [1.0, 1.0],
|
||||
topleft = [0.0, 1.0],
|
||||
),
|
||||
pos,
|
||||
[1.0, 1.0],
|
||||
)
|
||||
plotly_legend_pos(v::Tuple{S,T}) where {S<:Real, T<:Real} = v
|
||||
|
||||
function plotly_font(font::Font, color = font.color)
|
||||
KW(
|
||||
:family => font.family,
|
||||
@@ -285,18 +269,7 @@ function plotly_layout(plt::Plot)
|
||||
end
|
||||
|
||||
# legend
|
||||
plotattributes_out[:showlegend] = sp[:legend] != :none
|
||||
xpos,ypos = plotly_legend_pos(sp[:legend])
|
||||
if sp[:legend] != :none
|
||||
plotattributes_out[:legend] = KW(
|
||||
:bgcolor => rgba_string(sp[:background_color_legend]),
|
||||
:bordercolor => rgba_string(sp[:foreground_color_legend]),
|
||||
:font => plotly_font(legendfont(sp)),
|
||||
:tracegroupgap => 0,
|
||||
:x => xpos,
|
||||
:y => ypos
|
||||
)
|
||||
end
|
||||
plotly_add_legend!(plotattributes_out, sp)
|
||||
|
||||
# annotations
|
||||
for ann in sp[:annotations]
|
||||
@@ -336,9 +309,52 @@ function plotly_layout(plt::Plot)
|
||||
plotattributes_out[:hovermode] = "none"
|
||||
end
|
||||
|
||||
plotattributes_out
|
||||
plotattributes_out = recursive_merge(plotattributes_out, plt.attr[:extra_plot_kwargs])
|
||||
end
|
||||
|
||||
|
||||
function plotly_add_legend!(plotattributes_out::KW, sp::Subplot)
|
||||
plotattributes_out[:showlegend] = sp[:legend] != :none
|
||||
legend_position = plotly_legend_pos(sp[:legend])
|
||||
if sp[:legend] != :none
|
||||
plotattributes_out[:legend] = KW(
|
||||
:bgcolor => rgba_string(sp[:background_color_legend]),
|
||||
:bordercolor => rgba_string(sp[:foreground_color_legend]),
|
||||
:borderwidth => 1,
|
||||
:traceorder => "normal",
|
||||
:xanchor => legend_position.xanchor,
|
||||
:yanchor => legend_position.yanchor,
|
||||
:font => plotly_font(legendfont(sp)),
|
||||
:tracegroupgap => 0,
|
||||
:x => legend_position.coords[1],
|
||||
:y => legend_position.coords[2]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function plotly_legend_pos(pos::Symbol)
|
||||
xleft = 0.07
|
||||
ybot = 0.07
|
||||
ycenter = 0.52
|
||||
xcenter = 0.55
|
||||
plotly_legend_position_mapping = (
|
||||
right = (coords = [1.0, ycenter], xanchor = "right", yanchor = "middle"),
|
||||
left = (coords = [xleft, ycenter], xanchor = "left", yanchor = "middle"),
|
||||
top = (coords = [xcenter, 1.0], xanchor = "center", yanchor = "top"),
|
||||
bottom = (coords = [xcenter, ybot], xanchor = "center", yanchor = "bottom"),
|
||||
bottomleft = (coords = [xleft, ybot], xanchor = "left", yanchor = "bottom"),
|
||||
bottomright = (coords = [1.0, ybot], xanchor = "right", yanchor = "bottom"),
|
||||
topright = (coords = [1.0, 1.0], xanchor = "right", yanchor = "top"),
|
||||
topleft = (coords = [xleft, 1.0], xanchor = "left", yanchor = "top"),
|
||||
default = (coords = [1.02, 1.0], xanchor = "auto", yanchor = "auto")
|
||||
)
|
||||
|
||||
legend_position = get(plotly_legend_position_mapping, pos, plotly_legend_position_mapping.default)
|
||||
end
|
||||
|
||||
plotly_legend_pos(v::Tuple{S,T}) where {S<:Real, T<:Real} = (coords=v, xanchor="left", yanchor="top")
|
||||
|
||||
|
||||
function plotly_layout_json(plt::Plot)
|
||||
JSON.json(plotly_layout(plt), 4)
|
||||
end
|
||||
@@ -543,12 +559,6 @@ function plotly_series(plt::Plot, series::Series)
|
||||
plotattributes_out[:showscale] = hascolorbar(sp)
|
||||
end
|
||||
|
||||
elseif st == :pie
|
||||
plotattributes_out[:type] = "pie"
|
||||
plotattributes_out[:labels] = pie_labels(sp, series)
|
||||
plotattributes_out[:values] = y
|
||||
plotattributes_out[:hoverinfo] = "label+percent+name"
|
||||
|
||||
else
|
||||
@warn("Plotly: seriestype $st isn't supported.")
|
||||
return KW()
|
||||
@@ -816,9 +826,14 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt)
|
||||
const ijulia_initialized = Ref(false)
|
||||
|
||||
function plotly_html_head(plt::Plot)
|
||||
local_file = ("file://" * plotly_local_file_path)
|
||||
local_file = ("file:///" * plotly_local_file_path)
|
||||
plotly =
|
||||
use_local_dependencies[] ? local_file : "https://cdn.plot.ly/plotly-latest.min.js"
|
||||
use_local_dependencies[] ? local_file : "https://cdn.plot.ly/plotly-1.54.2.min.js"
|
||||
|
||||
include_mathjax = get(plt[:extra_plot_kwargs], :include_mathjax, "")
|
||||
mathjax_file = include_mathjax != "cdn" ? ("file://" * include_mathjax) : "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"
|
||||
mathjax_head = include_mathjax == "" ? "" : "<script src=\"$mathjax_file\"></script>\n\t\t"
|
||||
|
||||
if isijulia() && !ijulia_initialized[]
|
||||
# using requirejs seems to be key to load a js depency in IJulia!
|
||||
# https://requirejs.org/docs/start.html
|
||||
@@ -832,7 +847,7 @@ function plotly_html_head(plt::Plot)
|
||||
""")
|
||||
ijulia_initialized[] = true
|
||||
end
|
||||
return "<script src=$(repr(plotly))></script>"
|
||||
return "$mathjax_head<script src=$(repr(plotly))></script>"
|
||||
end
|
||||
|
||||
function plotly_html_body(plt, style = nothing)
|
||||
|
||||
+78
-40
@@ -13,6 +13,7 @@ append!(Base.Multimedia.displays, otherdisplays)
|
||||
pycolors = PyPlot.pyimport("matplotlib.colors")
|
||||
pypath = PyPlot.pyimport("matplotlib.path")
|
||||
mplot3d = PyPlot.pyimport("mpl_toolkits.mplot3d")
|
||||
axes_grid1 = PyPlot.pyimport("mpl_toolkits.axes_grid1")
|
||||
pypatches = PyPlot.pyimport("matplotlib.patches")
|
||||
pyfont = PyPlot.pyimport("matplotlib.font_manager")
|
||||
pyticker = PyPlot.pyimport("matplotlib.ticker")
|
||||
@@ -181,7 +182,7 @@ function labelfunc(scale::Symbol, backend::PyPlotBackend)
|
||||
elseif scale == :ln
|
||||
x -> PyPlot.LaTeXStrings.latexstring("e^{$x}")
|
||||
else
|
||||
string
|
||||
x -> PyPlot.LaTeXStrings.latexstring(convert_sci_unicode(x))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -517,7 +518,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
label = series[:label],
|
||||
zorder = series[:series_plotindex] + 0.5,
|
||||
marker = py_marker(_cycle(shapes,i)),
|
||||
s = py_thickness_scale(plt, _cycle(series[:markersize],i) .^ 2),
|
||||
s = py_thickness_scale(plt, _cycle(series[:markersize],i)).^ 2,
|
||||
facecolors = py_color(get_markercolor(series, i), get_markercoloralpha(series, i)),
|
||||
edgecolors = msc,
|
||||
linewidths = lw,
|
||||
@@ -548,7 +549,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
push!(cur_y_list, _cycle(y,i))
|
||||
|
||||
push!(cur_color_list, _cycle(markercolor, i))
|
||||
push!(cur_scale_list, py_thickness_scale(plt, _cycle(series[:markersize],i) .^ 2))
|
||||
push!(cur_scale_list, py_thickness_scale(plt, _cycle(series[:markersize],i)).^ 2)
|
||||
|
||||
continue
|
||||
end
|
||||
@@ -558,7 +559,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
zorder = series[:series_plotindex] + 0.5,
|
||||
marker = prev_marker,
|
||||
s = cur_scale_list,
|
||||
edgecolors = py_color(get_markerstrokecolor(series), get_markerstrokealpha(series)), # Do we need include i?
|
||||
edgecolors = py_color(get_markerstrokecolor(series), get_markerstrokealpha(series)),
|
||||
linewidths = py_thickness_scale(plt, series[:markerstrokewidth]),
|
||||
facecolors = cur_color_list,
|
||||
extrakw...
|
||||
@@ -568,7 +569,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
cur_y_list = [_cycle(y,i)]
|
||||
|
||||
cur_color_list = [_cycle(markercolor, i)]
|
||||
cur_scale_list = [py_thickness_scale(plt, _cycle(series[:markersize],i) .^ 2)]
|
||||
cur_scale_list = [py_thickness_scale(plt, _cycle(series[:markersize],i)) .^ 2]
|
||||
|
||||
prev_marker = cur_marker
|
||||
end
|
||||
@@ -589,11 +590,17 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
push!(handles, handle)
|
||||
else
|
||||
# do a normal scatter plot
|
||||
|
||||
# Add depthshade option for 3d plots
|
||||
if RecipesPipeline.is3d(sp)
|
||||
extrakw[:depthshade] = get(series[:extra_kwargs], :depthshade, false)
|
||||
end
|
||||
|
||||
handle = ax."scatter"(xyargs...;
|
||||
label = series[:label],
|
||||
zorder = series[:series_plotindex] + 0.5,
|
||||
marker = py_marker(series[:markershape]),
|
||||
s = py_thickness_scale(plt, series[:markersize] .^ 2),
|
||||
s = py_thickness_scale(plt, series[:markersize]) .^2,
|
||||
edgecolors = py_color(get_markerstrokecolor(series), get_markerstrokealpha(series)),
|
||||
linewidths = py_thickness_scale(plt, series[:markerstrokewidth]),
|
||||
extrakw...
|
||||
@@ -603,14 +610,16 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st == :hexbin
|
||||
handle = ax."hexbin"(x, y;
|
||||
handle = ax."hexbin"(x, y,
|
||||
label = series[:label],
|
||||
zorder = series[:series_plotindex],
|
||||
gridsize = series[:bins],
|
||||
C = series[:weights],
|
||||
gridsize = series[:bins]==:auto ? 100 : series[:bins], # 100 is the default value
|
||||
linewidths = py_thickness_scale(plt, series[:linewidth]),
|
||||
edgecolors = py_color(get_linecolor(series)),
|
||||
alpha = series[:fillalpha],
|
||||
cmap = py_fillcolormap(series), # applies to the pcolorfast object
|
||||
extrakw...
|
||||
zorder = series[:series_plotindex],
|
||||
# extrakw... # We are not supporting clims for hexbin as calculation of bins is not trivial
|
||||
)
|
||||
push!(handles, handle)
|
||||
end
|
||||
@@ -643,7 +652,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
extrakw...
|
||||
)
|
||||
if series[:contour_labels] == true
|
||||
PyPlot."clabel"(handle, handle.levels)
|
||||
ax."clabel"(handle, handle.levels)
|
||||
end
|
||||
push!(handles, handle)
|
||||
|
||||
@@ -652,6 +661,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
handle = ax."contourf"(x, y, z, levelargs...;
|
||||
label = series[:label],
|
||||
zorder = series[:series_plotindex] + 0.5,
|
||||
alpha = series[:fillalpha],
|
||||
extrakw...
|
||||
)
|
||||
push!(handles, handle)
|
||||
@@ -784,21 +794,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
push!(handles, handle)
|
||||
end
|
||||
|
||||
if st == :pie
|
||||
handle = ax."pie"(y;
|
||||
# colors = # a vector of colors?
|
||||
labels = pie_labels(sp, series)
|
||||
)[1]
|
||||
push!(handles, handle)
|
||||
|
||||
# # expand extrema... get list of Wedge objects
|
||||
# for wedge in handle
|
||||
# path = wedge[:get_path]()
|
||||
# for
|
||||
lim = 1.1
|
||||
expand_extrema!(sp, -lim, lim, -lim, lim)
|
||||
end
|
||||
|
||||
series[:serieshandle] = handles
|
||||
|
||||
# # smoothing
|
||||
@@ -1010,12 +1005,53 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
end
|
||||
kw[:spacing] = "proportional"
|
||||
|
||||
# create and store the colorbar object (handle) and the axis that it is drawn on.
|
||||
# note: the colorbar axis is positioned independently from the subplot axis
|
||||
fig = plt.o
|
||||
cbax = fig."add_axes"([0.8,0.1,0.03,0.8], label = string(gensym()))
|
||||
cb = fig."colorbar"(handle; cax = cbax, kw...)
|
||||
|
||||
if RecipesPipeline.is3d(sp)
|
||||
cbax = fig."add_axes"([0.9, 0.1, 0.03, 0.8])
|
||||
cb = fig."colorbar"(handle; cax=cbax, kw...)
|
||||
else
|
||||
# divider approach works only with 2d plots
|
||||
divider = axes_grid1.make_axes_locatable(ax)
|
||||
# width = axes_grid1.axes_size.AxesY(ax, aspect=1.0 / 3.5)
|
||||
# pad = axes_grid1.axes_size.Fraction(0.5, width) # Colorbar is spaced 0.5 of its size away from the ax
|
||||
# cbax = divider.append_axes("right", size=width, pad=pad) # This approach does not work well in subplots
|
||||
colorbar_position = "right"
|
||||
colorbar_pad = "2.5%"
|
||||
colorbar_orientation="vertical"
|
||||
|
||||
if sp[:colorbar] == :left
|
||||
colorbar_position = string(sp[:colorbar])
|
||||
colorbar_pad = "5%"
|
||||
elseif sp[:colorbar] == :top
|
||||
colorbar_position = string(sp[:colorbar])
|
||||
colorbar_pad = "2.5%"
|
||||
colorbar_orientation="horizontal"
|
||||
elseif sp[:colorbar] == :bottom
|
||||
colorbar_position = string(sp[:colorbar])
|
||||
colorbar_pad = "5%"
|
||||
colorbar_orientation="horizontal"
|
||||
end
|
||||
|
||||
cbax = divider.append_axes(colorbar_position, size="5%", pad=colorbar_pad) # Reasonable value works most of the usecases
|
||||
cb = fig."colorbar"(handle; cax=cbax, orientation = colorbar_orientation, kw...)
|
||||
|
||||
if sp[:colorbar] == :left
|
||||
cbax.yaxis.set_ticks_position("left")
|
||||
elseif sp[:colorbar] == :top
|
||||
cbax.xaxis.set_ticks_position("top")
|
||||
elseif sp[:colorbar] == :bottom
|
||||
cbax.xaxis.set_ticks_position("bottom")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
cb."set_label"(sp[:colorbar_title],size=py_thickness_scale(plt, sp[:yaxis][:guidefontsize]),family=sp[:yaxis][:guidefontfamily], color = py_color(sp[:yaxis][:guidefontcolor]))
|
||||
|
||||
# cb."formatter".set_useOffset(false) # This for some reason does not work, must be a pyplot bug, instead this is a workaround:
|
||||
cb."formatter".set_powerlimits((-Inf, Inf))
|
||||
cb."update_ticks"()
|
||||
|
||||
for lab in cb."ax"."yaxis"."get_ticklabels"()
|
||||
lab."set_fontsize"(py_thickness_scale(plt, sp[:yaxis][:tickfontsize]))
|
||||
lab."set_family"(sp[:yaxis][:tickfontfamily])
|
||||
@@ -1090,6 +1126,10 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
pyaxis."label"."set_fontsize"(py_thickness_scale(plt, axis[:guidefontsize]))
|
||||
pyaxis."label"."set_family"(axis[:guidefontfamily])
|
||||
|
||||
if (RecipesPipeline.is3d(sp))
|
||||
pyaxis."set_rotate_label"(false)
|
||||
end
|
||||
|
||||
if (letter == :y && !RecipesPipeline.is3d(sp))
|
||||
pyaxis."label"."set_rotation"(axis[:guidefontrotation] + 90)
|
||||
else
|
||||
@@ -1223,7 +1263,7 @@ function _update_min_padding!(sp::Subplot{PyPlotBackend})
|
||||
# optionally add the width of colorbar labels and colorbar to rightpad
|
||||
if haskey(sp.attr, :cbar_ax)
|
||||
bb = py_bbox(sp.attr[:cbar_handle]."ax"."get_yticklabels"())
|
||||
sp.attr[:cbar_width] = _cbar_width + width(bb) + 2.3mm + (sp[:colorbar_title] == "" ? 0px : 30px)
|
||||
sp.attr[:cbar_width] = _cbar_width + width(bb) + (sp[:colorbar_title] == "" ? 0px : 30px)
|
||||
rightpad = rightpad + sp.attr[:cbar_width]
|
||||
end
|
||||
|
||||
@@ -1322,16 +1362,17 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
||||
linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)),
|
||||
linestyle = py_linestyle(series[:seriestype], get_linestyle(series))
|
||||
)
|
||||
elseif series[:seriestype] in (:path, :straightline, :scatter)
|
||||
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :steppost)
|
||||
hasline = get_linewidth(series) > 0
|
||||
PyPlot.plt."Line2D"((0,1),(0,0),
|
||||
color = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
|
||||
linewidth = py_thickness_scale(plt, clamp(get_linewidth(series), 0, 5)),
|
||||
linewidth = py_thickness_scale(plt, hasline * sp[:legendfontsize] / 8),
|
||||
linestyle = py_linestyle(:path, get_linestyle(series)),
|
||||
marker = py_marker(_cycle(series[:markershape], 1)),
|
||||
# markersize = py_thickness_scale(plt, series[:markersize]), # In case we decide that markersize needs to be scaled in the legend too
|
||||
markersize = py_thickness_scale(plt, 0.8 * sp[:legendfontsize]),
|
||||
markeredgecolor = py_color(single_color(get_markerstrokecolor(series)), get_markerstrokealpha(series)),
|
||||
markerfacecolor = py_color(single_color(get_markercolor(series, clims)), get_markeralpha(series)),
|
||||
markeredgewidth = py_thickness_scale(plt, series[:markerstrokewidth])
|
||||
markeredgewidth = py_thickness_scale(plt, 0.8 * get_markerstrokewidth(series) * sp[:legendfontsize] / first(series[:markersize])) # retain the markersize/markerstroke ratio from the markers on the plot
|
||||
)
|
||||
else
|
||||
series[:serieshandle][1]
|
||||
@@ -1383,13 +1424,10 @@ function _update_plot_object(plt::Plot{PyPlotBackend})
|
||||
pcts = bbox_to_pcts(sp.plotarea, figw, figh)
|
||||
ax."set_position"(pcts)
|
||||
|
||||
# set the cbar position if there is one
|
||||
if haskey(sp.attr, :cbar_ax)
|
||||
if haskey(sp.attr, :cbar_ax) && RecipesPipeline.is3d(sp) # 2D plots are completely handled by axis dividers
|
||||
cbw = sp.attr[:cbar_width]
|
||||
# this is the bounding box of just the colors of the colorbar (not labels)
|
||||
ex = sp[:zaxis][:extrema]
|
||||
has_toplabel = !(1e-7 < max(abs(ex.emax), abs(ex.emin)) < 1e7)
|
||||
cb_bbox = BoundingBox(right(sp.bbox)-cbw+1mm, top(sp.bbox) + (has_toplabel ? 4mm : 2mm), _cbar_width-1mm, height(sp.bbox) - (has_toplabel ? 6mm : 4mm))
|
||||
cb_bbox = BoundingBox(right(sp.bbox)-cbw - 2mm, top(sp.bbox) + 2mm, _cbar_width-1mm, height(sp.bbox) - 4mm)
|
||||
pcts = bbox_to_pcts(cb_bbox, figw, figh)
|
||||
sp.attr[:cbar_ax]."set_position"(pcts)
|
||||
end
|
||||
|
||||
+26
-8
@@ -358,9 +358,15 @@ end
|
||||
Scales all **current** font sizes by `factor`. For example `scalefontsizes(1.1)` increases all current font sizes by 10%. To reset to initial sizes, use `scalefontsizes()`
|
||||
"""
|
||||
function scalefontsizes(factor::Number)
|
||||
for k in (:titlefontsize, :guidefontsize, :tickfontsize, :legendfontsize)
|
||||
for k in (:titlefontsize, :legendfontsize, :legendtitlefontsize)
|
||||
scalefontsize(k, factor)
|
||||
end
|
||||
|
||||
for letter in (:x,:y,:z)
|
||||
for k in (:guidefontsize, :tickfontsize)
|
||||
scalefontsize(Symbol(letter, k), factor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
"""
|
||||
@@ -369,15 +375,27 @@ end
|
||||
Resets font sizes to initial default values.
|
||||
"""
|
||||
function scalefontsizes()
|
||||
for k in (:titlefontsize, :guidefontsize, :tickfontsize, :legendfontsize)
|
||||
f = default(k)
|
||||
if k in keys(_initial_fontsizes)
|
||||
factor = f / _initial_fontsizes[k]
|
||||
scalefontsize(k, 1.0/factor)
|
||||
end
|
||||
end
|
||||
for k in (:titlefontsize, :legendfontsize, :legendtitlefontsize)
|
||||
f = default(k)
|
||||
if k in keys(_initial_fontsizes)
|
||||
factor = f / _initial_fontsizes[k]
|
||||
scalefontsize(k, 1.0/factor)
|
||||
end
|
||||
end
|
||||
|
||||
for letter in (:x,:y,:z)
|
||||
for k in (:guidefontsize, :tickfontsize)
|
||||
if k in keys(_initial_fontsizes)
|
||||
f = default(Symbol(letter, k))
|
||||
factor = f / _initial_fontsizes[k]
|
||||
scalefontsize(Symbol(letter, k), 1.0/factor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resetfontsizes() = scalefontsizes()
|
||||
|
||||
"Wrap a string with font info"
|
||||
struct PlotText
|
||||
str::AbstractString
|
||||
|
||||
@@ -998,14 +998,11 @@ _backend_skips = Dict(
|
||||
6, # images
|
||||
10, # histogram2d
|
||||
16, # pgfplots thinks the upper panel is too small
|
||||
22, # contourf
|
||||
23, # pie
|
||||
25, # @df
|
||||
30, # @df
|
||||
31, # animation
|
||||
32, # spy
|
||||
38, # histogram2d
|
||||
45, # wireframe
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
+1
-9
@@ -29,49 +29,41 @@ function __init__()
|
||||
@require HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" begin
|
||||
fn = joinpath(@__DIR__, "backends", "hdf5.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require InspectDR = "d0351b0e-4b05-5898-87b3-e2a8edfddd1d" begin
|
||||
fn = joinpath(@__DIR__, "backends", "inspectdr.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa" begin
|
||||
fn = joinpath(@__DIR__, "backends", "pgfplots.jl")
|
||||
fn = joinpath(@__DIR__, "backends", "deprecated", "pgfplots.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require ORCA = "47be7bcc-f1a6-5447-8b36-7eeeff7534fd" begin
|
||||
fn = joinpath(@__DIR__, "backends", "orca.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" begin
|
||||
fn = joinpath(@__DIR__, "backends", "pgfplotsx.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" begin
|
||||
fn = joinpath(@__DIR__, "backends", "plotlyjs.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" begin
|
||||
fn = joinpath(@__DIR__, "backends", "pyplot.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" begin
|
||||
fn = joinpath(@__DIR__, "backends", "unicodeplots.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin
|
||||
|
||||
+31
-2
@@ -155,8 +155,23 @@ RecipesPipeline.type_alias(plt::Plot) = get(_typeAliases, st, st)
|
||||
function RecipesPipeline.plot_setup!(plt::Plot, plotattributes, kw_list)
|
||||
_plot_setup(plt, plotattributes, kw_list)
|
||||
_subplot_setup(plt, plotattributes, kw_list)
|
||||
return nothing
|
||||
end
|
||||
|
||||
function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_list)
|
||||
# swap errors
|
||||
err_inds = findall(kw -> get(kw, :seriestype, :path) in (:xerror, :yerror, :zerror), kw_list)
|
||||
for ind in err_inds
|
||||
if get(kw_list[ind-1],:seriestype,:path) == :scatter
|
||||
tmp = copy(kw_list[ind])
|
||||
kw_list[ind] = copy(kw_list[ind-1])
|
||||
kw_list[ind-1] = tmp
|
||||
end
|
||||
end
|
||||
return nothing
|
||||
end
|
||||
|
||||
|
||||
# TODO: Should some of this logic be moved to RecipesPipeline?
|
||||
function _plot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
|
||||
# merge in anything meant for the Plot
|
||||
@@ -274,6 +289,7 @@ function RecipesPipeline.slice_series_attributes!(plt::Plot, kw_list, kw)
|
||||
# in series attributes given as vector with one element per series,
|
||||
# select the value for current series
|
||||
_slice_series_args!(kw, plt, sp, series_idx(kw_list, kw))
|
||||
return nothing
|
||||
end
|
||||
|
||||
RecipesPipeline.series_defaults(plt::Plot) = _series_defaults # in args.jl
|
||||
@@ -330,7 +346,7 @@ function _expand_subplot_extrema(sp::Subplot, plotattributes::AKW, st::Symbol)
|
||||
ymin, ymax = ignorenan_extrema(plotattributes[:y])
|
||||
expand_extrema!(sp[:xaxis], (xmin, xmax))
|
||||
expand_extrema!(sp[:yaxis], (ymin, ymax))
|
||||
elseif !(st in (:pie, :histogram, :bins2d, :histogram2d))
|
||||
elseif !(st in (:histogram, :bins2d, :histogram2d))
|
||||
expand_extrema!(sp, plotattributes)
|
||||
end
|
||||
# expand for zerolines (axes through origin)
|
||||
@@ -341,7 +357,20 @@ function _expand_subplot_extrema(sp::Subplot, plotattributes::AKW, st::Symbol)
|
||||
end
|
||||
|
||||
function _add_the_series(plt, sp, plotattributes)
|
||||
warn_on_unsupported_args(plt.backend, plotattributes)
|
||||
extra_kwargs = warn_on_unsupported_args(plt.backend, plotattributes)
|
||||
if (kw = plt[:extra_kwargs]) isa AbstractDict
|
||||
plt[:extra_plot_kwargs] = get(kw,:plot,KW())
|
||||
sp[:extra_kwargs] = get(kw,:subplot, KW())
|
||||
plotattributes[:extra_kwargs] = get(kw,:series,KW())
|
||||
elseif plt[:extra_kwargs] == :plot
|
||||
plt[:extra_plot_kwargs] = extra_kwargs
|
||||
elseif plt[:extra_kwargs] == :subplot
|
||||
sp[:extra_kwargs] = extra_kwargs
|
||||
elseif plt[:extra_kwargs] == :series
|
||||
plotattributes[:extra_kwargs] = extra_kwargs
|
||||
else
|
||||
ArgumentError("Unsupported type for extra keyword arguments")
|
||||
end
|
||||
warn_on_unsupported(plt.backend, plotattributes)
|
||||
series = Series(plotattributes)
|
||||
push!(plt.series_list, series)
|
||||
|
||||
+15
-22
@@ -9,7 +9,6 @@ function _precompile_()
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:formatter,), Tuple{typeof(RecipesPipeline.datetimeformatter)}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:grid, :lims), Tuple{Bool, Tuple{Int64, Int64}}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:grid, :lims, :flip), Tuple{Bool, Tuple{Int64, Int64}, Bool}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:grid, :ticks), Tuple{Bool, Nothing}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:grid,), Tuple{Bool}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:gridlinewidth, :grid, :gridalpha, :gridstyle, :foreground_color_grid), Tuple{Int64, Bool, Float64, Symbol, ColorTypes.RGBA{Float64}}}, typeof(Plots.attr!), Plots.Axis})
|
||||
isdefined(Plots, Symbol("#attr!##kw")) && precompile(Tuple{getfield(Plots, Symbol("#attr!##kw")), NamedTuple{(:guide,), Tuple{String}}, typeof(Plots.attr!), Plots.Axis})
|
||||
@@ -332,7 +331,6 @@ function _precompile_()
|
||||
precompile(Tuple{typeof(Plots.get_markercolor), Plots.Series, Float64, Float64, Int64})
|
||||
precompile(Tuple{typeof(Plots.get_markerstrokealpha), Plots.Series, Int64})
|
||||
precompile(Tuple{typeof(Plots.get_markerstrokecolor), Plots.Series, Int64})
|
||||
precompile(Tuple{typeof(Plots.get_markerstrokewidth), Plots.Series, Int64})
|
||||
precompile(Tuple{typeof(Plots.get_minor_ticks), Plots.Subplot{Plots.GRBackend}, Plots.Axis, Tuple{Array{Float64, 1}, Array{Any, 1}}})
|
||||
precompile(Tuple{typeof(Plots.get_minor_ticks), Plots.Subplot{Plots.GRBackend}, Plots.Axis, Tuple{Array{Float64, 1}, Array{String, 1}}})
|
||||
precompile(Tuple{typeof(Plots.get_minor_ticks), Plots.Subplot{Plots.GRBackend}, Plots.Axis, Tuple{Array{Int64, 1}, Array{String, 1}}})
|
||||
@@ -359,26 +357,24 @@ function _precompile_()
|
||||
precompile(Tuple{typeof(Plots.gr_display), Plots.Plot{Plots.GRBackend}, String})
|
||||
precompile(Tuple{typeof(Plots.gr_display), Plots.Subplot{Plots.GRBackend}, Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}, Array{Float64, 1}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_colorbar), Plots.GRColorbar, Plots.Subplot{Plots.GRBackend}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Int64, Int64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Int64, Int64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Float64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Float64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Int64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Int64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Int64, Tuple{Float64, Float64}, Int64, Int64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Int64, Tuple{Float64, Float64}, Int64, Int64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Float64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Int64, Float64, Float64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Int64, Float64, Float64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Float64, Float64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Float64, Tuple{Float64, Float64}, Int64, Float64, Float64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Int64, Tuple{Float64, Float64}, Int64, Float64, Float64, Plots.Shape})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_marker), Plots.Series, Int64, Int64, Tuple{Float64, Float64}, Int64, Float64, Float64, Symbol})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Float64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Float64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Float64, 1}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Int64, 1}, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Int64, 1}, Tuple{Float64, Float64}, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Array{Int64, 1}, Array{Int64, 1}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.OneTo{Int64}, Array{Float64, 1}, Tuple{Float64, Float64}, Array{Float64, 1}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.OneTo{Int64}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.OneTo{Int64}, Array{Float64, 1}, Tuple{Float64, Float64}, Array{Float64, 1}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.OneTo{Int64}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.OneTo{Int64}, Array{Float64, 1}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Array{Float64, 1}, Tuple{Float64, Float64}, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, Array{Float64, 1}, Tuple{Float64, Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_draw_markers), Plots.Series, Float64, Float64, Tuple{Float64, Float64}, Float64, Float64})
|
||||
precompile(Tuple{typeof(Plots.gr_fill_viewport), Array{Float64, 1}, ColorTypes.RGBA{Float64}})
|
||||
precompile(Tuple{typeof(Plots.gr_get_ticks_size), Tuple{Array{Float64, 1}, Array{Any, 1}}, Int64})
|
||||
precompile(Tuple{typeof(Plots.gr_get_ticks_size), Tuple{Array{Float64, 1}, Array{String, 1}}, Int64})
|
||||
@@ -526,8 +522,8 @@ function _precompile_()
|
||||
precompile(Tuple{typeof(Plots.optimal_ticks_and_labels), Plots.Subplot{Plots.PlotlyBackend}, Plots.Axis, Base.UnitRange{Int64}})
|
||||
precompile(Tuple{typeof(Plots.optimal_ticks_and_labels), Plots.Subplot{Plots.PlotlyBackend}, Plots.Axis, Nothing})
|
||||
precompile(Tuple{typeof(Plots.parse_axis_kw), Symbol})
|
||||
precompile(Tuple{typeof(Plots.pie_labels), Plots.Subplot{Plots.GRBackend}, Plots.Series})
|
||||
precompile(Tuple{typeof(Plots.pie_labels), Plots.Subplot{Plots.PlotlyBackend}, Plots.Series})
|
||||
precompile(Tuple{typeof(Plots.partialcircle), Float64, Float64, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.partialcircle), Int64, Float64, Int64, Int64})
|
||||
precompile(Tuple{typeof(Plots.plotarea!), Plots.GridLayout, Measures.BoundingBox{Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}, Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}}})
|
||||
precompile(Tuple{typeof(Plots.plotarea!), Plots.Subplot{Plots.GRBackend}, Measures.BoundingBox{Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}, Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}}})
|
||||
precompile(Tuple{typeof(Plots.plotarea!), Plots.Subplot{Plots.PlotlyBackend}, Measures.BoundingBox{Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}, Tuple{Measures.Length{:mm, Float64}, Measures.Length{:mm, Float64}}}})
|
||||
@@ -542,10 +538,8 @@ function _precompile_()
|
||||
precompile(Tuple{typeof(Plots.plotly_colorscale), PlotUtils.ContinuousColorGradient, Nothing})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Array{Float64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Array{Int64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Array{String, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Array{Float64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Array{Int64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Array{String, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Base.OneTo{Int64}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}})
|
||||
precompile(Tuple{typeof(Plots.plotly_data), Plots.Series, Symbol, Base.StepRange{Int64, Int64}})
|
||||
@@ -565,7 +559,6 @@ function _precompile_()
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Array{Float64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Array{Float64, 2}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Array{Int64, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Array{String, 1}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Base.OneTo{Int64}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}})
|
||||
precompile(Tuple{typeof(Plots.plotly_native_data), Plots.Axis, Base.StepRange{Int64, Int64}})
|
||||
|
||||
+50
-54
@@ -71,8 +71,9 @@ const POTENTIAL_VECTOR_ARGUMENTS = [
|
||||
:marker_z,
|
||||
:markerstrokecolor,
|
||||
:markerstrokealpha,
|
||||
:xerror,
|
||||
:yerror,
|
||||
:yerror,
|
||||
:zerror,
|
||||
:series_annotations,
|
||||
:fillrange,
|
||||
]
|
||||
@@ -111,7 +112,7 @@ end
|
||||
|
||||
@recipe function f(::Type{Val{:hline}}, x, y, z)
|
||||
n = length(y)
|
||||
newx = repeat(Float64[-1, 1, NaN], n)
|
||||
newx = repeat(Float64[1, 2, NaN], n)
|
||||
newy = vec(Float64[yi for i = 1:3, yi in y])
|
||||
x := newx
|
||||
y := newy
|
||||
@@ -123,7 +124,7 @@ end
|
||||
@recipe function f(::Type{Val{:vline}}, x, y, z)
|
||||
n = length(y)
|
||||
newx = vec(Float64[yi for i = 1:3, yi in y])
|
||||
newy = repeat(Float64[-1, 1, NaN], n)
|
||||
newy = repeat(Float64[1, 2, NaN], n)
|
||||
x := newx
|
||||
y := newy
|
||||
seriestype := :straightline
|
||||
@@ -459,7 +460,7 @@ end
|
||||
@deps plots_heatmap shape
|
||||
is_3d(::Type{Val{:plots_heatmap}}) = true
|
||||
RecipesPipeline.is_surface(::Type{Val{:plots_heatmap}}) = true
|
||||
|
||||
RecipesPipeline.is_surface(::Type{Val{:hexbin}}) = true
|
||||
# ---------------------------------------------------------------------------
|
||||
# Histograms
|
||||
|
||||
@@ -537,14 +538,19 @@ end
|
||||
@recipe function f(::Type{Val{:scatterbins}}, x, y, z)
|
||||
edge, weights, xscale, yscale, baseline =
|
||||
_preprocess_binlike(plotattributes, x, y)
|
||||
xerror := diff(edge) / 2
|
||||
@series begin
|
||||
x := _bin_centers(edge)
|
||||
xerror := diff(edge) / 2
|
||||
primary := false
|
||||
seriestype := :xerror
|
||||
()
|
||||
end
|
||||
x := _bin_centers(edge)
|
||||
y := weights
|
||||
seriestype := :scatter
|
||||
()
|
||||
end
|
||||
@deps scatterbins scatter
|
||||
|
||||
@deps scatterbins xerror scatter
|
||||
|
||||
function _stepbins_path(
|
||||
edge,
|
||||
@@ -885,6 +891,28 @@ end
|
||||
end
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# pie
|
||||
@recipe function f(::Type{Val{:pie}}, x, y, z)
|
||||
framestyle --> :none
|
||||
aspect_ratio --> true
|
||||
s = sum(y)
|
||||
θ = 0
|
||||
for i in eachindex(y)
|
||||
θ_new = θ + 2π * y[i] / s
|
||||
coords = [(0.0, 0.0); partialcircle(θ, θ_new, 50)]
|
||||
@series begin
|
||||
seriestype := :shape
|
||||
label --> string(x[i])
|
||||
x := first.(coords)
|
||||
y := last.(coords)
|
||||
end
|
||||
θ = θ_new
|
||||
end
|
||||
end
|
||||
@deps pie shape
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# scatter 3d
|
||||
|
||||
@@ -1000,7 +1028,7 @@ end
|
||||
|
||||
function error_style!(plotattributes::AKW)
|
||||
plotattributes[:seriestype] = :path
|
||||
plotattributes[:linecolor] = plotattributes[:markerstrokecolor]
|
||||
plotattributes[:markercolor] = plotattributes[:markerstrokecolor]
|
||||
plotattributes[:linewidth] = plotattributes[:markerstrokewidth]
|
||||
plotattributes[:label] = ""
|
||||
end
|
||||
@@ -1072,7 +1100,7 @@ end
|
||||
end
|
||||
()
|
||||
end
|
||||
@deps xerror path
|
||||
@deps zerror path
|
||||
|
||||
|
||||
# TODO: move quiver to PlotRecipes
|
||||
@@ -1387,7 +1415,7 @@ end
|
||||
@recipe function f(::Type{Val{:spy}}, x, y, z)
|
||||
yflip := true
|
||||
aspect_ratio := 1
|
||||
rs, cs, zs = findnz(z.surf)
|
||||
rs, cs, zs = Plots.findnz(z.surf)
|
||||
xlims := ignorenan_extrema(cs)
|
||||
ylims := ignorenan_extrema(rs)
|
||||
if plotattributes[:markershape] == :none
|
||||
@@ -1407,6 +1435,18 @@ end
|
||||
()
|
||||
end
|
||||
|
||||
|
||||
Plots.findnz(A::AbstractSparseMatrix) = findnz(A)
|
||||
|
||||
# fallback function for finding non-zero elements of non-sparse matrices
|
||||
function Plots.findnz(A::AbstractMatrix)
|
||||
keysnz = findall(!iszero, A)
|
||||
rs = [k[1] for k in keysnz]
|
||||
cs = [k[2] for k in keysnz]
|
||||
zs = A[keysnz]
|
||||
rs, cs, zs
|
||||
end
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
"Adds ax+b... straight line over the current plot, without changing the axis limits"
|
||||
@@ -1434,50 +1474,6 @@ end
|
||||
end
|
||||
|
||||
|
||||
# --------------------------------------------------
|
||||
# Color Gradients
|
||||
|
||||
@userplot ShowLibrary
|
||||
@recipe function f(cl::ShowLibrary)
|
||||
if !(length(cl.args) == 1 && isa(cl.args[1], Symbol))
|
||||
error("showlibrary takes the name of a color library as a Symbol")
|
||||
end
|
||||
|
||||
library = PlotUtils.color_libraries[cl.args[1]]
|
||||
z = sqrt.((1:15) * reshape(1:20, 1, :))
|
||||
|
||||
seriestype := :heatmap
|
||||
ticks := nothing
|
||||
legend := false
|
||||
|
||||
layout --> length(library.lib)
|
||||
|
||||
i = 0
|
||||
for grad in sort(collect(keys(library.lib)))
|
||||
@series begin
|
||||
seriescolor := cgrad(grad, cl.args[1])
|
||||
title := string(grad)
|
||||
subplot := i += 1
|
||||
z
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@userplot ShowGradient
|
||||
@recipe function f(grad::ShowGradient)
|
||||
if !(length(grad.args) == 1 && isa(grad.args[1], Symbol))
|
||||
error("showgradient takes the name of a color gradient as a Symbol")
|
||||
end
|
||||
z = sqrt.((1:15) * reshape(1:20, 1, :))
|
||||
seriestype := :heatmap
|
||||
ticks := nothing
|
||||
legend := false
|
||||
seriescolor := grad.args[1]
|
||||
title := string(grad.args[1])
|
||||
z
|
||||
end
|
||||
|
||||
|
||||
# Moved in from PlotRecipes - see: http://stackoverflow.com/a/37732384/5075246
|
||||
@userplot PortfolioComposition
|
||||
|
||||
|
||||
+1
-2
@@ -381,8 +381,7 @@ julia> curves([1,2,3,4],[1,1,2,4])
|
||||
@shorthands curves
|
||||
|
||||
"Plot a pie diagram"
|
||||
pie(args...; kw...) = plot(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
||||
pie!(args...; kw...) = plot!(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
||||
@shorthands pie
|
||||
|
||||
"Plot with seriestype :path3d"
|
||||
plot3d(args...; kw...) = plot(args...; kw..., seriestype = :path3d)
|
||||
|
||||
+18
-6
@@ -42,12 +42,24 @@ get_subplot_index(plt::Plot, sp::Subplot) = findfirst(x -> x === sp, plt.subplot
|
||||
series_list(sp::Subplot) = sp.series_list # filter(series -> series.plotattributes[:subplot] === sp, sp.plt.series_list)
|
||||
|
||||
function should_add_to_legend(series::Series)
|
||||
series.plotattributes[:primary] && series.plotattributes[:label] != "" &&
|
||||
!(series.plotattributes[:seriestype] in (
|
||||
:hexbin,:bins2d,:histogram2d,:hline,:vline,
|
||||
:contour,:contourf,:contour3d,:surface,:wireframe,
|
||||
:heatmap, :pie, :image
|
||||
))
|
||||
series.plotattributes[:primary] &&
|
||||
series.plotattributes[:label] != "" &&
|
||||
!(
|
||||
series.plotattributes[:seriestype] in (
|
||||
:hexbin,
|
||||
:bins2d,
|
||||
:histogram2d,
|
||||
:hline,
|
||||
:vline,
|
||||
:contour,
|
||||
:contourf,
|
||||
:contour3d,
|
||||
:surface,
|
||||
:wireframe,
|
||||
:heatmap,
|
||||
:image,
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
+96
-32
@@ -75,7 +75,11 @@ function iter_segments(series::Series)
|
||||
if series[:seriestype] in (:scatter, :scatter3d)
|
||||
return [[i] for i in eachindex(y)]
|
||||
else
|
||||
return [i:(i + 1) for i in firstindex(y):lastindex(y)-1]
|
||||
if any(isnan,y)
|
||||
return [iter_segments(y)...]
|
||||
else
|
||||
return [i:(i + 1) for i in firstindex(y):lastindex(y)-1]
|
||||
end
|
||||
end
|
||||
else
|
||||
segs = UnitRange{Int}[]
|
||||
@@ -298,6 +302,11 @@ Base.convert(::Type{Vector{T}}, rng::AbstractRange{S}) where {T<:Real,S<:Real} =
|
||||
|
||||
Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b)))
|
||||
|
||||
# recursively merge kw-dicts, e.g. for merging extra_kwargs / extra_plot_kwargs in plotly)
|
||||
recursive_merge(x::AbstractDict...) = merge(recursive_merge, x...)
|
||||
# if values are not AbstractDicts, take the last definition (as does merge)
|
||||
recursive_merge(x...) = x[end]
|
||||
|
||||
nanpush!(a::AbstractVector, b) = (push!(a, NaN); push!(a, b))
|
||||
nanappend!(a::AbstractVector, b) = (push!(a, NaN); append!(a, b))
|
||||
|
||||
@@ -410,44 +419,46 @@ xlims(sp_idx::Int = 1) = xlims(current(), sp_idx)
|
||||
ylims(sp_idx::Int = 1) = ylims(current(), sp_idx)
|
||||
zlims(sp_idx::Int = 1) = zlims(current(), sp_idx)
|
||||
|
||||
# These functions return an operator for use in `get_clims(::Seres, op)`
|
||||
process_clims(lims::Tuple{<:Number,<:Number}) = (zlims -> ifelse.(isfinite.(lims), lims, zlims)) ∘ ignorenan_extrema
|
||||
process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema
|
||||
# don't specialize on ::Function otherwise python functions won't work
|
||||
process_clims(f) = f
|
||||
|
||||
function get_clims(sp::Subplot)
|
||||
function get_clims(sp::Subplot, op=process_clims(sp[:clims]))
|
||||
zmin, zmax = Inf, -Inf
|
||||
for series in series_list(sp)
|
||||
if series[:colorbar_entry]
|
||||
zmin, zmax = _update_clims(zmin, zmax, get_clims(series)...)
|
||||
zmin, zmax = _update_clims(zmin, zmax, get_clims(series, op)...)
|
||||
end
|
||||
end
|
||||
clims = sp[:clims]
|
||||
if is_2tuple(clims)
|
||||
isfinite(clims[1]) && (zmin = clims[1])
|
||||
isfinite(clims[2]) && (zmax = clims[2])
|
||||
end
|
||||
return zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
end
|
||||
|
||||
function get_clims(sp::Subplot, series::Series)
|
||||
function get_clims(sp::Subplot, series::Series, op=process_clims(sp[:clims]))
|
||||
zmin, zmax = if series[:colorbar_entry]
|
||||
get_clims(sp)
|
||||
get_clims(sp, op)
|
||||
else
|
||||
get_clims(series)
|
||||
end
|
||||
clims = sp[:clims]
|
||||
if is_2tuple(clims)
|
||||
isfinite(clims[1]) && (zmin = clims[1])
|
||||
isfinite(clims[2]) && (zmax = clims[2])
|
||||
get_clims(series, op)
|
||||
end
|
||||
return zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
end
|
||||
|
||||
function get_clims(series::Series)
|
||||
"""
|
||||
get_clims(::Series, op=Plots.ignorenan_extrema)
|
||||
|
||||
Finds the limits for the colorbar by taking the "z-values" for the series and passing them into `op`,
|
||||
which must return the tuple `(zmin, zmax)`. The default op is the extrema of the finite
|
||||
values of the input.
|
||||
"""
|
||||
function get_clims(series::Series, op=ignorenan_extrema)
|
||||
zmin, zmax = Inf, -Inf
|
||||
z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface)
|
||||
z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin)
|
||||
for vals in (series[:seriestype] in z_colored_series ? series[:z] : nothing, series[:line_z], series[:marker_z], series[:fill_z])
|
||||
if (typeof(vals) <: AbstractSurface) && (eltype(vals.surf) <: Union{Missing, Real})
|
||||
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals.surf)...)
|
||||
zmin, zmax = _update_clims(zmin, zmax, op(vals.surf)...)
|
||||
elseif (vals !== nothing) && (eltype(vals) <: Union{Missing, Real})
|
||||
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals)...)
|
||||
zmin, zmax = _update_clims(zmin, zmax, op(vals)...)
|
||||
end
|
||||
end
|
||||
return zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
|
||||
@@ -481,7 +492,7 @@ end
|
||||
hascolorbar(series::Series) = colorbar_style(series) !== nothing
|
||||
hascolorbar(sp::Subplot) = sp[:colorbar] != :none && any(hascolorbar(s) for s in series_list(sp))
|
||||
|
||||
iscontour(series::Series) = series[:seriestype] == :contour
|
||||
iscontour(series::Series) = series[:seriestype] in (:contour, :contour3d)
|
||||
isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing
|
||||
|
||||
function contour_levels(series::Series, clims)
|
||||
@@ -587,7 +598,28 @@ function has_attribute_segments(series::Series)
|
||||
end
|
||||
series[:seriestype] == :shape && return false
|
||||
# ... else we check relevant attributes if they have multiple inputs
|
||||
return any((typeof(series[attr]) <: AbstractVector && length(series[attr]) > 1) for attr in [:seriescolor, :seriesalpha, :linecolor, :linealpha, :linewidth, :linestyle, :fillcolor, :fillalpha, :markercolor, :markeralpha, :markerstrokecolor, :markerstrokealpha]) || any(typeof(series[attr]) <: AbstractArray for attr in (:line_z, :fill_z, :marker_z))
|
||||
return any(
|
||||
(typeof(series[attr]) <: AbstractVector && length(series[attr]) > 1)
|
||||
for
|
||||
attr in [
|
||||
:seriescolor,
|
||||
:seriesalpha,
|
||||
:linecolor,
|
||||
:linealpha,
|
||||
:linewidth,
|
||||
:linestyle,
|
||||
:fillcolor,
|
||||
:fillalpha,
|
||||
:markercolor,
|
||||
:markeralpha,
|
||||
:markersize,
|
||||
:markerstrokecolor,
|
||||
:markerstrokealpha,
|
||||
:markerstrokewidth,
|
||||
]
|
||||
) || any(
|
||||
typeof(series[attr]) <: AbstractArray for attr in (:line_z, :fill_z, :marker_z)
|
||||
)
|
||||
end
|
||||
|
||||
function get_aspect_ratio(sp)
|
||||
@@ -603,6 +635,17 @@ function get_aspect_ratio(sp)
|
||||
return aspect_ratio
|
||||
end
|
||||
|
||||
get_size(kw) = get(kw, :size, default(:size))
|
||||
get_size(plt::Plot) = get_size(plt.attr)
|
||||
get_size(sp::Subplot) = get_size(sp.plt)
|
||||
get_size(series::Series) = get_size(series.plotattributes[:subplot])
|
||||
|
||||
get_thickness_scaling(kw) = get(kw, :thickness_scaling, default(:thickness_scaling))
|
||||
get_thickness_scaling(plt::Plot) = get_thickness_scaling(plt.attr)
|
||||
get_thickness_scaling(sp::Subplot) = get_thickness_scaling(sp.plt)
|
||||
get_thickness_scaling(series::Series) =
|
||||
get_thickness_scaling(series.plotattributes[:subplot])
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
makekw(; kw...) = KW(kw)
|
||||
@@ -945,7 +988,7 @@ px2inch(px::Real) = float(px / PX_PER_INCH)
|
||||
inch2mm(inches::Real) = float(inches * MM_PER_INCH)
|
||||
mm2inch(mm::Real) = float(mm / MM_PER_INCH)
|
||||
px2mm(px::Real) = float(px * MM_PER_PX)
|
||||
mm2px(mm::Real) = float(px / MM_PER_PX)
|
||||
mm2px(mm::Real) = float(mm / MM_PER_PX)
|
||||
|
||||
|
||||
"Smallest x in plot"
|
||||
@@ -1036,10 +1079,21 @@ end
|
||||
function straightline_data(series, expansion_factor = 1)
|
||||
sp = series[:subplot]
|
||||
xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp))
|
||||
x, y = series[:x], series[:y]
|
||||
|
||||
# handle axes scales
|
||||
xscale = sp[:xaxis][:scale]
|
||||
xf = RecipesPipeline.scale_func(xscale)
|
||||
xinvf = RecipesPipeline.inverse_scale_func(xscale)
|
||||
yscale = sp[:yaxis][:scale]
|
||||
yf = RecipesPipeline.scale_func(yscale)
|
||||
yinvf = RecipesPipeline.inverse_scale_func(yscale)
|
||||
|
||||
xl, yl = xf.(xl), yf.(yl)
|
||||
x, y = xf.(series[:x]), yf.(series[:y])
|
||||
n = length(x)
|
||||
if n == 2
|
||||
return straightline_data(xl, yl, x, y, expansion_factor)
|
||||
|
||||
xdata, ydata = if n == 2
|
||||
straightline_data(xl, yl, x, y, expansion_factor)
|
||||
else
|
||||
k, r = divrem(n, 3)
|
||||
if r == 0
|
||||
@@ -1048,11 +1102,13 @@ function straightline_data(series, expansion_factor = 1)
|
||||
inds = (3 * i - 2):(3 * i - 1)
|
||||
xdata[inds], ydata[inds] = straightline_data(xl, yl, x[inds], y[inds], expansion_factor)
|
||||
end
|
||||
return xdata, ydata
|
||||
xdata, ydata
|
||||
else
|
||||
error("Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n")
|
||||
end
|
||||
end
|
||||
|
||||
return xinvf.(xdata), yinvf.(ydata)
|
||||
end
|
||||
|
||||
function straightline_data(xl, yl, x, y, expansion_factor = 1)
|
||||
@@ -1084,20 +1140,28 @@ end
|
||||
function shape_data(series, expansion_factor = 1)
|
||||
sp = series[:subplot]
|
||||
xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp))
|
||||
|
||||
# handle axes scales
|
||||
xscale = sp[:xaxis][:scale]
|
||||
xf = RecipesPipeline.scale_func(xscale)
|
||||
xinvf = RecipesPipeline.inverse_scale_func(xscale)
|
||||
yscale = sp[:yaxis][:scale]
|
||||
yf = RecipesPipeline.scale_func(yscale)
|
||||
yinvf = RecipesPipeline.inverse_scale_func(yscale)
|
||||
|
||||
x, y = copy(series[:x]), copy(series[:y])
|
||||
factor = 100
|
||||
for i in eachindex(x)
|
||||
if x[i] == -Inf
|
||||
x[i] = xl[1] - expansion_factor * (xl[2] - xl[1])
|
||||
x[i] = xinvf(xf(xl[1]) - expansion_factor * (xf(xl[2]) - xf(xl[1])))
|
||||
elseif x[i] == Inf
|
||||
x[i] = xl[2] + expansion_factor * (xl[2] - xl[1])
|
||||
x[i] = xinvf(xf(xl[2]) + expansion_factor * (xf(xl[2]) - xf(xl[1])))
|
||||
end
|
||||
end
|
||||
for i in eachindex(y)
|
||||
if y[i] == -Inf
|
||||
y[i] = yl[1] - expansion_factor * (yl[2] - yl[1])
|
||||
y[i] = yinvf(yf(yl[1]) - expansion_factor * (yf(yl[2]) - yf(yl[1])))
|
||||
elseif y[i] == Inf
|
||||
y[i] = yl[2] + expansion_factor * (yl[2] - yl[1])
|
||||
y[i] = yinvf(yf(yl[2]) + expansion_factor * (yf(yl[2]) - yf(yl[1])))
|
||||
end
|
||||
end
|
||||
return x, y
|
||||
|
||||
@@ -9,6 +9,7 @@ using LibGit2
|
||||
using GeometryTypes
|
||||
using Dates
|
||||
|
||||
include("test_axes.jl")
|
||||
include("test_hdf5plots.jl")
|
||||
include("test_pgfplotsx.jl")
|
||||
|
||||
@@ -178,4 +179,9 @@ end
|
||||
@test isequal(collect(zip(Plots.unzip(z)...)), z)
|
||||
@test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z)
|
||||
end
|
||||
op1 = Plots.process_clims((1.0, 2.0))
|
||||
op2 = Plots.process_clims((1, 2.0))
|
||||
data = randn(100, 100)
|
||||
@test op1(data) == op2(data)
|
||||
@test Plots.process_clims(nothing) == Plots.process_clims(missing) == Plots.process_clims(:auto)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Plots, Test
|
||||
|
||||
@testset "Showaxis" begin
|
||||
for value in Plots._allShowaxisArgs
|
||||
@test plot(1:5, showaxis = value)[1][:yaxis][:showaxis] isa Bool
|
||||
end
|
||||
@test plot(1:5, showaxis = :y)[1][:yaxis][:showaxis] == true
|
||||
@test plot(1:5, showaxis = :y)[1][:xaxis][:showaxis] == false
|
||||
end
|
||||
|
||||
@testset "Magic axis" begin
|
||||
@test plot(1, axis=nothing)[1][:xaxis][:ticks] == []
|
||||
@test plot(1, axis=nothing)[1][:yaxis][:ticks] == []
|
||||
end # testset
|
||||
@@ -326,3 +326,23 @@ end
|
||||
# end
|
||||
end # testset
|
||||
end # testset
|
||||
|
||||
@testset "Extra kwargs" begin
|
||||
pl = plot(1:5, test = "me")
|
||||
@test pl[1][1].plotattributes[:extra_kwargs][:test] == "me"
|
||||
pl = plot(1:5, test = "me", extra_kwargs = :subplot)
|
||||
@test pl[1].attr[:extra_kwargs][:test] == "me"
|
||||
pl = plot(1:5, test = "me", extra_kwargs = :plot)
|
||||
@test pl.attr[:extra_plot_kwargs][:test] == "me"
|
||||
pl = plot(1:5, extra_kwargs = Dict(:plot => Dict(:test => "me"), :series => Dict(:and => "me too")))
|
||||
@test pl.attr[:extra_plot_kwargs][:test] == "me"
|
||||
@test pl[1][1].plotattributes[:extra_kwargs][:and] == "me too"
|
||||
pl = plot(
|
||||
plot(1:5, title="Line"),
|
||||
scatter(1:5, title="Scatter", extra_kwargs=Dict(:subplot=>Dict("axis line shift" => "10pt")))
|
||||
)
|
||||
Plots._update_plot_object(pl)
|
||||
axes = Plots.pgfx_axes(pl.o)
|
||||
@test !haskey(axes[1].options.dict, "axis line shift")
|
||||
@test haskey(axes[2].options.dict, "axis line shift")
|
||||
end # testset
|
||||
|
||||
Reference in New Issue
Block a user