Compare commits

...

115 Commits

Author SHA1 Message Date
Simon Christ 0762a29de3 Cap PGFPlotsX 2020-06-17 16:57:13 +02:00
Rashika Karki d6af1da35a Fix #2771: Add aliases (#2791)
* Fix #2771: Add aliases

* Added function to add aliases from vector
2020-06-17 14:37:01 +02:00
Daniel Schwabeneder bbbee44c66 Merge pull request #2793 from daschw/gr-3d
add legend line in GR for 3d paths
2020-06-17 14:25:37 +02:00
Daniel Schwabeneder 9499cef25d add legend line in GR for 3d paths 2020-06-17 11:54:53 +02:00
Simon Christ 7c8952fadf bump version [skip ci] 2020-06-17 11:19:26 +02:00
isentropic 8b2d3e926a better exopnents (#2786) 2020-06-17 11:18:03 +02:00
Fons van der Plas fb40ed1f59 Plotly fixed version (#2779)
* Fixed version for plotly.js dependency

* Fixed version for plotly.js dependency - .gitignore update
2020-06-17 11:17:37 +02:00
isentropic e88654cca5 pyplot colorbar positioning (#2772) 2020-06-17 11:17:18 +02:00
Maaz Bin Tahir Saeed a9b9b3c357 Fix #2377, #2785, #2369: Legend positioning fix for multiple plots (#2784)
* Fix 2377: Legend positioning fix for multiple vertical plots

* Fix #2785: Legend positioning for multiple horizontal plots
2020-06-17 11:16:37 +02:00
Simon Christ 99c8bfe12d bump version [skip ci] 2020-06-16 09:44:37 +02:00
Simon Christ 3eb2b783dc keep LaTeXStrings to be LaTeXStrings (#2781) 2020-06-16 09:39:07 +02:00
Daniel Schwabeneder a20b275eaf Merge pull request #2788 from jheinen/master
gr: fix polar heatmap problem
2020-06-16 09:23:43 +02:00
Josef Heinen c29694ae70 gr: fix polar heatmap problem 2020-06-15 12:53:57 +02:00
Simon Christ ebc93b6935 remove Pkg (#2776)
* remove Pkg

* remove using Pkg
2020-06-10 12:03:13 +02:00
isentropic 7dcbe911b1 Legends documentation and some todos (#2770)
* improve legends documentation

* todo additional legend positions

* Update plotly.jl

removed todo
2020-06-09 13:30:06 +02:00
Simon Christ c2df99cc66 remove showgradient and showlibrary (#2769) 2020-06-09 08:38:43 +02:00
isentropic a992effa5e scalefontsize fixed (#2765) 2020-06-09 08:37:39 +02:00
Simon Christ e49eb9bc83 update badges (#2761)
* update badges

* Update README.md
[skip ci]
2020-06-06 10:13:25 +02:00
Daniel Schwabeneder f2d7d394bb Merge pull request #2760 from daschw/gr-heatmap
improve nonuniform heatmap performance on GR
2020-06-05 19:55:16 +02:00
Daniel Schwabeneder 87d40cd34d improve nonuniform heatmap performance on GR 2020-06-05 18:23:48 +02:00
Daniel Schwabeneder 5f24f88f12 Merge pull request #2757 from daschw/release
bump version [skip ci]
2020-06-04 13:34:07 +02:00
Daniel Schwabeneder 9c465b58db bump version [skip ci] 2020-06-04 13:33:15 +02:00
Daniel Schwabeneder ad4a00c055 Merge pull request #2755 from jamblejoe/fix/spy
Plots.findnz for sparse and non-sparse matrices
2020-06-04 13:31:30 +02:00
Daniel Schwabeneder 54671c15d7 Merge pull request #2751 from isentropic/plotly-legends
plotly legend fixes
2020-06-04 11:42:20 +02:00
Daniel Schwabeneder fff8f84acf Merge pull request #2748 from daschw/tests
Remove travis and appveyour config files
2020-06-04 00:25:17 +02:00
Daniel Schwabeneder 4d8ea50f69 Merge pull request #2754 from daschw/current-stable
Add missing commits
2020-06-04 00:24:19 +02:00
Goran Nakerst 43f31cbc98 Plots.findnz for sparse and non-sparse matrices 2020-06-03 23:06:23 +01:00
Daniel Schwabeneder d98e76e36d Merge remote-tracking branch 'origin/master' into current-stable 2020-06-03 23:29:41 +02:00
Zhanibek e2a5e40019 plotly legend fixes 2020-06-03 16:08:53 +09:00
Daniel Schwabeneder 3c2c2c18d7 Remove travis and appveyour config files 2020-06-01 09:58:22 +02:00
Daniel Schwabeneder 0ee1d867c9 Merge pull request #2745 from aminya/GitHubActions
GitHub actions
2020-06-01 09:46:34 +02:00
Amin Yahyaabadi b145ea9ef5 typo 2020-05-31 02:38:38 -05:00
Daniel Schwabeneder 73971896ee Merge pull request #2744 from giordano/patch-1
Remove duplicate entries in the Project file
2020-05-31 09:29:42 +02:00
Amin Yahyaabadi f5f4128e30 Add ci.yml 2020-05-30 20:41:23 -05:00
Mosè Giordano 70dfa52a9a Remove duplicate entries in the Project files 2020-05-31 01:05:04 +01:00
Josef Heinen 2e53c57114 bump GR version 2020-05-29 16:49:51 +02:00
Simon Christ 0485b1313a bump version [skip ci] 2020-05-29 15:16:15 +02:00
Daniel Schwabeneder f0f28086a9 Merge pull request #2740 from daschw/vline
fix infinite objects with log scale
2020-05-29 10:50:04 +02:00
Daniel Schwabeneder 580ac8a9d1 fix infinite objects with log scale 2020-05-29 09:42:44 +02:00
Daniel Schwabeneder 84fc6b0be0 Merge pull request #2739 from mileslucas/patch-1
fix type restriction in process_clims
2020-05-28 08:37:13 +02:00
Miles Lucas de81220c01 fix namespace 2020-05-27 12:16:20 -10:00
Miles Lucas ee1f948448 add process_clims tests 2020-05-27 12:00:53 -10:00
Miles Lucas 995c7d349e fix type restriction in process_clims 2020-05-27 11:55:49 -10:00
Simon Christ 4389160a6a bumb version [skip ci] 2020-05-27 15:23:48 +02:00
Simon Christ 8c6295658b fix showaxis fix (#2737)
* also replace axis syms

* process showaxis

* fix axis keyword
2020-05-27 15:23:02 +02:00
Simon Christ a270e342b7 bump version [skip ci] 2020-05-26 20:41:45 +02:00
Simon Christ 42e2266530 Fix showaxis (#2733)
* also replace axis syms

* include test_axes [skip ci]

* Create test_axes.jl

* process showaxis
2020-05-26 20:40:44 +02:00
Cornelius-G 02e6d729c1 add attribute fillalpha to contourf seriestype for pyplot backend (#2732) 2020-05-26 18:37:58 +02:00
Tim Holy baac9a0578 Remove explicit Revise.track from atsign-require blocks (#2734)
* Remove explicit Revise.track from atsign-require blocks

Since Revise 2.4, it has no longer been necessary to explicitly call
Revise.track, as Revise handles this internally.

Also related: https://github.com/timholy/Revise.jl/pull/487,
which checks to see whether Revise.track was called via atsign-require
and if so return without doing anything.

* Bump Requires [compat] to 1
2020-05-26 18:37:13 +02:00
Simon Christ b73dd46521 bump version [skip ci] 2020-05-25 15:01:42 +02:00
isentropic 7bbb2070a7 pyplot colorbar fixes (#2722)
* pyplot colorbar fixes

* pyplot colorbar fixes

* pyplot: sligtly reworked colorbars

* pyplot 3d color bar fixes

* pyplot 3d color bar fixes
2020-05-25 15:00:56 +02:00
Simon Christ 8859518f2d update compat bounds (#2727) 2020-05-25 10:05:33 +02:00
Simon Christ 7f063c71b5 bump version [skip ci] 2020-05-21 12:35:16 +02:00
hhaensel 1e9691a7c0 Add support for mathjax (latex) and extra_plot_kwargs in plotly backend (#2719)
* support mathjax header in plotly backend

* support extra_plot_kwargs in plotly backend

* correct local file parameter to `file:///`

* corrections proposed by @BeastyBlacksmith

* include extra_kwargs for subplots

* don't merge subplot extra_kwargs

Co-authored-by: Helmut Haensel <M136270@eu.merckgroup.com>
Co-authored-by: Simon Christ <SimonChrist@gmx.de>
2020-05-21 12:32:25 +02:00
Simon Christ e5269bcf95 bump version [skip ci] 2020-05-20 15:56:25 +02:00
Simon Christ fdd76a6ca1 Update bug.md 2020-05-20 15:55:52 +02:00
Simon Christ d19525c269 improve title- and legendlocation (#2718)
* improve titlelocation

* fix default case

* improve legend position
2020-05-20 14:55:19 +02:00
Simon Christ 593331dec2 change default alignment in legends (#2714) 2020-05-19 21:20:14 +02:00
Simon Christ b780d90097 minor bump [skip ci] 2020-05-19 13:04:49 +02:00
Simon Christ 2f9ce790e4 deprecate pgfplots (#2711)
* deprecate pgfplots

* Update backends.jl

* Update backends.jl

* Rename src/backends/pgfplots.jl to src/backends/deprecated/pgfplots.jl

* Update init.jl
2020-05-19 13:03:54 +02:00
Simon Christ d8f4519b0c bump version [skip ci] 2020-05-17 10:29:13 +02:00
Simon Christ 702e41f55d add all guide_positions (#2710)
* add all guide_positions

* remove show
2020-05-17 10:28:21 +02:00
Simon Christ 682ac29fcd fix clims (#2709) 2020-05-16 20:10:39 +02:00
Simon Christ c6ce23d0af bump version [skip ci] 2020-05-14 14:45:00 +02:00
Daniel Schwabeneder 9ae7d2dd9d Merge pull request #2700 from daschw/pgfx-colorbar
pgfplotsx colorbar improvements
2020-05-14 14:17:41 +02:00
isentropic 6ec05628d5 python depthshade (#2703)
* python depthshade

* python depthshade
2020-05-14 12:26:18 +02:00
Daniel Schwabeneder f26ebdc2f1 remove unused color strings 2020-05-13 17:21:18 +02:00
Daniel Schwabeneder c97255fc08 don't make colorbars thinner 2020-05-13 17:03:52 +02:00
Daniel Schwabeneder 9d1ede016b make colorbars thinner 2020-05-13 17:03:52 +02:00
Daniel Schwabeneder 7eb8f2452c colorbar positions :top, :bottom and :left and colorbar tickfont fixes 2020-05-13 17:03:52 +02:00
Daniel Schwabeneder 0a6e691222 allow disabling the colorbar in pgfplotsx 2020-05-13 17:03:52 +02:00
jamblejoe 238aca6a78 added description for argument legendtitle (#2697) 2020-05-12 18:32:21 +02:00
Simon Christ 1f039b3adc bump version [skip ci] 2020-05-11 16:52:42 +02:00
Simon Christ 219465d599 fix contours (#2692)
* fix 2d-contour

* fix filled contours (colorbar is off)

* activate fixed examples
2020-05-11 16:52:00 +02:00
Simon Christ 1963cee94a fix it again (#2694) 2020-05-11 16:51:38 +02:00
Simon Christ ae43e05f6f bump version [skip ci] 2020-05-09 13:10:32 +02:00
Simon Christ 5cd2ba7296 Delete tmpplotsave.hdf5 2020-05-09 13:09:53 +02:00
isentropic 4a00018f25 pyplot hexbin (#2679)
* pyplot hexbin

* pyplot hexbin changes
2020-05-09 13:07:32 +02:00
Simon Christ 32c725e770 error bars behind in scatterplots (#2677)
* errors behind for :scatter

* fix plots with no seriestype
2020-05-09 13:05:15 +02:00
Daniel Schwabeneder 4e2ee35125 Merge pull request #2684 from daschw/gr-ticklabel
fix numeric gr ticklabels
2020-05-08 10:15:04 +02:00
Daniel Schwabeneder 35b0751714 fix numeric gr ticklabels 2020-05-07 18:17:47 +02:00
Zh 28ebc0ccd8 pyplot hexbin 2020-05-07 03:02:00 +09:00
Simon Christ 3d693d88e0 Change color handling of error recipes (#2675)
* fix iteration of segments

* fix error vector arg detection

* change color handling of recipes
2020-05-06 18:21:54 +02:00
Daniel Schwabeneder 6ddf31d465 Merge pull request #2673 from komi1230/master
Removed arrow3d from gr.jl in backends/
2020-05-05 20:50:40 +02:00
Yusuke Kominami 5c1ea707ca removed unnecessary args 2020-05-06 01:24:20 +09:00
Yusuke Kominami a6669f89a0 removed arrow3d 2020-05-05 23:18:03 +09:00
Simon Christ 2a2d509c36 Version bump
[skip ci]
2020-05-05 10:26:56 +02:00
isentropic fd4efb3f33 PyPlot: z-axis guidefontrotation only works for short labels Fix 2641 (#2667) 2020-05-05 10:26:01 +02:00
isentropic e90ab0b898 PyPlot fix contour labels (#2668) 2020-05-05 10:25:12 +02:00
Simon Christ 44367c54da fix quiver (#2670) 2020-05-05 10:24:15 +02:00
Daniel Schwabeneder 3273a65889 Merge pull request #2657 from mileslucas/climsfunc
allow passing a function to `clims`
2020-05-05 08:18:07 +02:00
Miles Lucas 0aa606d835 fix typo in get_clims function docstring 2020-05-04 11:05:53 -10:00
Simon Christ 40848e7432 fix error recipes (#2665)
* fix scatterbins

* fix zerror
2020-05-04 18:16:29 +02:00
Michael Krabbe Borregaard fe4cc4d58c update patch version 2020-05-04 18:12:20 +02:00
Daniel Schwabeneder 56f90ffaf3 Merge pull request #2663 from dietercastel/webm
Added webm support for animations.
2020-05-03 19:28:49 +02:00
Daniel Schwabeneder dfb556339f Merge pull request #2662 from daschw/plotarea
GR size fixes
2020-05-03 15:54:56 +02:00
Daniel Schwabeneder 61f5a7f437 fix extra_kwargs docs string 2020-05-03 15:39:51 +02:00
Daniel Schwabeneder 3be9b8d076 fix outer legend font size 2020-05-03 15:37:12 +02:00
Daniel Schwabeneder 2a138dee40 fix get_size and get_thickness_scaling for series 2020-05-03 15:37:12 +02:00
Daniel Schwabeneder 712ef74b81 remove const _gr_plot_size, _gr_point_mult and _gr_thickness_scaling 2020-05-03 15:37:12 +02:00
Daniel Schwabeneder ba8ca424cf remove gloabal viewport_plotarea in gr 2020-05-03 15:37:12 +02:00
Dieter Castel c6784a779b Added webm support for animations. 2020-05-03 15:31:55 +02:00
Simon Christ d667cb7e57 update documentation of extra_kwargs 2020-05-03 15:10:34 +02:00
Miles Lucas 10a5c2ed1d fix bug with Tuple clims and fix typos 2020-05-01 00:10:27 -10:00
Miles Lucas 8cce78c890 fix typos 2020-04-30 23:38:52 -10:00
Miles Lucas 294ade8aad refactor get_clims calls to use operators 2020-04-30 23:32:30 -10:00
Miles Lucas a59e8411c9 update clims arg description 2020-04-30 22:30:03 -10:00
Daniel Schwabeneder d973f437ef Merge pull request #2653 from daschw/segments
make segments for vectors of markersize and markerstrokewidth
2020-04-30 14:05:45 +02:00
Josef Heinen d5ce2c1431 Merge remote-tracking branch 'upstream/master' 2020-04-30 13:25:06 +02:00
Josef Heinen 834e2a99e3 add actual GR version 2020-04-30 13:18:32 +02:00
Daniel Schwabeneder f8e9e33347 Merge pull request #2650 from daschw/pyplot
pyplot legend marker fixes
2020-04-30 13:17:53 +02:00
Daniel Schwabeneder a0c7781296 make segments for vectors of markersize and markerstrokewidth 2020-04-30 13:16:33 +02:00
Daniel Schwabeneder 2ea998983d fix legend marker for vector of markersizes [skip ci] 2020-04-30 10:04:04 +02:00
Daniel Schwabeneder e44b220b84 fix legend marker linewidth for steppre and steppost [skip ci] 2020-04-30 10:03:21 +02:00
Daniel Schwabeneder 756cccb114 remove lines in legend markers for scatter plots in pyplot [skip ci] 2020-04-30 09:46:13 +02:00
28 changed files with 814 additions and 554 deletions
+2 -2
View File
@@ -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()`:
+86
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -1,7 +1,7 @@
name = "Plots"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
author = ["Tom Breloff (@tbreloff)"]
version = "1.2.0"
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"]
+3 -7
View File
@@ -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,8 +12,7 @@
[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]
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://julialang.zulipchat.com/#narrow/stream/236493-plots)
[![][docs-img]][docs-url]
-46
View File
@@ -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%"
+4 -4
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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.",
+20 -4
View File
@@ -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]
@@ -502,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)
@@ -583,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)
@@ -622,7 +637,7 @@ for arg in keys(_series_defaults)
_keyAliases[makeplural(arg)] = arg
end
add_non_underscore_aliases!(_keyAliases)
# -----------------------------------------------------------------------------
@@ -944,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
+4 -11
View File
@@ -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)
+7 -4
View File
@@ -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
@@ -828,6 +830,7 @@ const _pgfplotsx_seriestype = [
:heatmap,
:contour,
:contour3d,
:quiver,
:shape,
:steppre,
:stepmid,
+252 -185
View File
File diff suppressed because it is too large Load Diff
+101 -73
View File
@@ -136,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),
@@ -184,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)
@@ -206,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))
@@ -288,7 +285,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
extra_series = wraptuple(pop!(extra_series_opt,:add))
end
series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...))
if RecipesPipeline.is3d(series) || st == :heatmap
if RecipesPipeline.is3d(series) || st in (:heatmap, :contour)
series_func = PGFPlotsX.Plot3
else
series_func = PGFPlotsX.Plot
@@ -297,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
@@ -342,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,
@@ -596,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
@@ -606,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(
@@ -655,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"),
@@ -677,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
@@ -953,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)
@@ -1018,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
@@ -1114,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,
@@ -1212,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 -32
View File
@@ -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
@@ -810,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
@@ -826,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)
+72 -19
View File
@@ -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
@@ -589,6 +590,12 @@ 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,
@@ -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)
@@ -995,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])
@@ -1075,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
@@ -1208,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
@@ -1307,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, sp[:legendfontsize] / 8),
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, 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, 0.8 * series[:markerstrokewidth] * sp[:legendfontsize] / series[:markersize]) # retain the markersize/markerstroke ratio from the markers on the plot
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]
@@ -1368,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
View File
@@ -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
-2
View File
@@ -998,13 +998,11 @@ _backend_skips = Dict(
6, # images
10, # histogram2d
16, # pgfplots thinks the upper panel is too small
22, # contourf
25, # @df
30, # @df
31, # animation
32, # spy
38, # histogram2d
45, # wireframe
],
)
+1 -9
View File
@@ -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
+16
View File
@@ -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
+28 -54
View File
@@ -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,
@@ -1022,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
@@ -1094,7 +1100,7 @@ end
end
()
end
@deps xerror path
@deps zerror path
# TODO: move quiver to PlotRecipes
@@ -1409,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
@@ -1429,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"
@@ -1456,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
+96 -32
View File
@@ -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
+6
View File
@@ -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
+14
View File
@@ -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
BIN
View File
Binary file not shown.