added clims attribute and support it in pyplot
This commit is contained in:
parent
8007d0dd6a
commit
cf4d78c87c
@ -74,6 +74,7 @@ const _arg_desc = KW(
|
|||||||
: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.",
|
: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 Symbol (legend position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:inside`, `:legend`, `:topright`, `:topleft`, `:bottomleft`, `:bottomright` (note: only some may be supported in each backend)",
|
:legend => "Bool (show the legend?) or Symbol (legend position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:inside`, `:legend`, `:topright`, `:topleft`, `:bottomleft`, `:bottomright` (note: only some may be supported in each backend)",
|
||||||
: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)",
|
: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.",
|
||||||
:legendfont => "Font. Font of legend items.",
|
:legendfont => "Font. Font of legend items.",
|
||||||
:grid => "Bool. Show the grid lines?",
|
:grid => "Bool. Show the grid lines?",
|
||||||
: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.",
|
: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.",
|
||||||
|
|||||||
@ -214,6 +214,7 @@ const _subplot_defaults = KW(
|
|||||||
:color_palette => :auto,
|
:color_palette => :auto,
|
||||||
:legend => :best,
|
:legend => :best,
|
||||||
:colorbar => :legend,
|
:colorbar => :legend,
|
||||||
|
:clims => :auto,
|
||||||
:legendfont => font(8),
|
:legendfont => font(8),
|
||||||
:grid => true,
|
:grid => true,
|
||||||
:annotations => [], # annotation tuples... list of (x,y,annotation)
|
:annotations => [], # annotation tuples... list of (x,y,annotation)
|
||||||
@ -388,6 +389,7 @@ add_aliases(:zticks, :ztick)
|
|||||||
add_aliases(:zrotation, :zrot, :zr)
|
add_aliases(:zrotation, :zrot, :zr)
|
||||||
add_aliases(:legend, :leg, :key)
|
add_aliases(:legend, :leg, :key)
|
||||||
add_aliases(:colorbar, :cb, :cbar, :colorkey)
|
add_aliases(:colorbar, :cb, :cbar, :colorkey)
|
||||||
|
add_aliases(:clims, :clim, :cbarlims, :cbar_lims, :climits, :color_limits)
|
||||||
add_aliases(:smooth, :regression, :reg)
|
add_aliases(:smooth, :regression, :reg)
|
||||||
add_aliases(:levels, :nlevels, :nlev, :levs)
|
add_aliases(:levels, :nlevels, :nlev, :levs)
|
||||||
add_aliases(:size, :windowsize, :wsize)
|
add_aliases(:size, :windowsize, :wsize)
|
||||||
|
|||||||
@ -36,6 +36,7 @@ supportedArgs(::PyPlotBackend) = [
|
|||||||
:normalize, :weights, :contours, :aspect_ratio,
|
:normalize, :weights, :contours, :aspect_ratio,
|
||||||
:match_dimensions,
|
:match_dimensions,
|
||||||
:subplot,
|
:subplot,
|
||||||
|
:clims,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotBackend) = _allAxes
|
supportedAxes(::PyPlotBackend) = _allAxes
|
||||||
supportedTypes(::PyPlotBackend) = [
|
supportedTypes(::PyPlotBackend) = [
|
||||||
@ -502,6 +503,11 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
else
|
else
|
||||||
extrakw[:c] = convert(Vector{Float64}, d[:marker_z])
|
extrakw[:c] = convert(Vector{Float64}, d[:marker_z])
|
||||||
extrakw[:cmap] = pymarkercolormap(d)
|
extrakw[:cmap] = pymarkercolormap(d)
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
xyargs = if st in (:bar, :sticks) && !isvertical(d)
|
xyargs = if st in (:bar, :sticks) && !isvertical(d)
|
||||||
@ -546,13 +552,19 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if st == :histogram2d
|
if st == :histogram2d
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
handle = ax[:hist2d](x, y;
|
handle = ax[:hist2d](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
bins = d[:bins],
|
bins = d[:bins],
|
||||||
normed = d[:normalize],
|
normed = d[:normalize],
|
||||||
weights = d[:weights],
|
weights = d[:weights],
|
||||||
cmap = pyfillcolormap(d) # applies to the pcolorfast object
|
cmap = pyfillcolormap(d), # applies to the pcolorfast object
|
||||||
|
extrakw...
|
||||||
)[4]
|
)[4]
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
@ -565,13 +577,19 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if st == :hexbin
|
if st == :hexbin
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
handle = ax[:hexbin](x, y;
|
handle = ax[:hexbin](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
gridsize = d[:bins],
|
gridsize = d[:bins],
|
||||||
linewidths = d[:linewidth],
|
linewidths = d[:linewidth],
|
||||||
edgecolors = pylinecolor(d),
|
edgecolors = pylinecolor(d),
|
||||||
cmap = pyfillcolormap(d) # applies to the pcolorfast object
|
cmap = pyfillcolormap(d), # applies to the pcolorfast object
|
||||||
|
extrakw...
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
@ -594,6 +612,11 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
z = transpose_z(d, z.surf)
|
z = transpose_z(d, z.surf)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
|
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
|
|
||||||
if st == :contour3d
|
if st == :contour3d
|
||||||
extrakw[:extend3d] = true
|
extrakw[:extend3d] = true
|
||||||
@ -635,6 +658,11 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
if d[:marker_z] != nothing
|
if d[:marker_z] != nothing
|
||||||
extrakw[:facecolors] = getPyPlotCustomShading(d[:fillcolor], d[:marker_z], d[:fillalpha])
|
extrakw[:facecolors] = getPyPlotCustomShading(d[:fillcolor], d[:marker_z], d[:fillalpha])
|
||||||
extrakw[:shade] = false
|
extrakw[:shade] = false
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
extrakw[:cmap] = pyfillcolormap(d)
|
extrakw[:cmap] = pyfillcolormap(d)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
@ -672,12 +700,18 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
|
|
||||||
elseif typeof(z) <: AbstractVector
|
elseif typeof(z) <: AbstractVector
|
||||||
# tri-surface plot (http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#tri-surface-plots)
|
# tri-surface plot (http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#tri-surface-plots)
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
handle = ax[:plot_trisurf](x, y, z;
|
handle = ax[:plot_trisurf](x, y, z;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
cmap = pyfillcolormap(d),
|
cmap = pyfillcolormap(d),
|
||||||
linewidth = d[:linewidth],
|
linewidth = d[:linewidth],
|
||||||
edgecolor = pylinecolor(d)
|
edgecolor = pylinecolor(d),
|
||||||
|
extrakw...
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
@ -719,11 +753,19 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
if !isempty(dvals)
|
if !isempty(dvals)
|
||||||
discrete_colorbar_values = dvals
|
discrete_colorbar_values = dvals
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clims = sp[:clims]
|
||||||
|
if isa(clims, Tuple) && length(clims) == 2
|
||||||
|
isfinite(clims[1]) && (extrakw[:vmin] = clims[1])
|
||||||
|
isfinite(clims[2]) && (extrakw[:vmax] = clims[2])
|
||||||
|
end
|
||||||
|
|
||||||
handle = ax[:pcolormesh](x, y, z;
|
handle = ax[:pcolormesh](x, y, z;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
cmap = pyfillcolormap(d),
|
cmap = pyfillcolormap(d),
|
||||||
edgecolors = (d[:linewidth] > 0 ? pylinecolor(d) : "face")
|
edgecolors = (d[:linewidth] > 0 ? pylinecolor(d) : "face"),
|
||||||
|
extrakw...
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user