|
1 | 1 |
|
2 | 2 | """ |
3 | | -PyPlot allows Julia to interface with the Matplotlib library in Python, specifically the matplotlib.pyplot module, so you can create beautiful plots in Julia with your favorite Python package. |
| 3 | +PyPlot allows Julia to interface with the Matplotlib library in Python, specifically the matplotlib.pyplot module, so you can create beautiful plots in Julia with your favorite Python package. |
4 | 4 |
|
5 | | -Only the currently documented matplotlib.pyplot API is exported. To use other functions in the module, you can also call matplotlib.pyplot.foo(...) as plt.foo(...). |
| 5 | +Only the currently documented matplotlib.pyplot API is exported. To use other functions in the module, you can also call matplotlib.pyplot.foo(...) as plt.foo(...). |
6 | 6 | For example, plt.plot(x, y) also works. (And the raw PyObject for the matplotlib modules is also accessible as PyPlot.matplotlib.) |
7 | 7 |
|
8 | | -In general, all the arguments are the same as in Python. |
| 8 | +In general, all the arguments are the same as in Python. |
9 | 9 |
|
10 | 10 | Here's a brief demo of a simple plot in Julia: |
11 | | - |
| 11 | +
|
12 | 12 | using PyPlot |
13 | 13 | x = range(0; stop=2*pi, length=1000); y = sin.(3 * x + 4 * cos.(2 * x)); |
14 | 14 | plot(x, y, color="red", linewidth=2.0, linestyle="--") |
@@ -220,14 +220,15 @@ include("colormaps.jl") |
220 | 220 | ########################################################################### |
221 | 221 | # Support array of string labels in bar chart |
222 | 222 |
|
223 | | -function bar(x::AbstractVector{T}, y; kws...) where T<:AbstractString |
| 223 | +function bar(x::AbstractVector{<:AbstractString}, y; kws_...) |
| 224 | + kws = Dict{Any,Any}(kws_) |
224 | 225 | xi = 1:length(x) |
225 | | - if !any(kw -> kw[1] == :align, kws) |
226 | | - push!(kws, (:align, "center")) |
| 226 | + if !any(==(:align), keys(kws)) |
| 227 | + kws[:align] = "center" |
227 | 228 | end |
228 | 229 | p = bar(xi, y; kws...) |
229 | 230 | ax = any(kw -> kw[1] == :orientation && lowercase(kw[2]) == "horizontal", |
230 | | - kws) ? gca()."yaxis" : gca()."xaxis" |
| 231 | + pairs(kws)) ? gca()."yaxis" : gca()."xaxis" |
231 | 232 | ax."set_ticks"(xi) |
232 | 233 | ax."set_ticklabels"(x) |
233 | 234 | return p |
|
0 commit comments