You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using DataFrames, Plots, Statistics, RDatasets
iris_df =dataset("datasets", "iris")
cor_mat =cor(Matrix(iris_df[:, 1:4]), dims=1)
col_names =names(iris_df)[1:end-1]
heatmap(
col_names, col_names, cor_mat,
rightmargin=20Plots.mm,
leftmargin=10Plots.mm,
aspect_ratio=:equal,
size=(700, 700),
title="Correlation heatmap between 4 features of the Iris dataset",
xlabel="Features", ylabel="Features",
colorbar_title="Correlation",
color=:bluesreds,
framestyle=:box,
titlefont=font(12)
)
plot!(dpi=200)
savefig("cor.png")
Leads to
Then I tried to shrink the color bar length to fit the plot. So first, I began with changing the backend to pyplot and pythonplot and moving the dpi into the heatmap function:
pyplot()
heatmap(
col_names, col_names, cor_mat,
rightmargin=20Plots.mm,
leftmargin=10Plots.mm,
aspect_ratio=:equal,
size=(700, 700),
title="Correlation heatmap between 4 features of the Iris dataset",
xlabel="Features", ylabel="Features",
colorbar_title="Correlation",
color=:bluesreds,
framestyle=:box,
titlefont=font(12),
dpi=300
)
savefig("cor.png")
And in the VSCode plot pane, it shows:
But the result of savefig is the same as unshrinked version!! :D
Backends
This bug occurs on ( insert x below )
Backend
yes
no
untested
gr (default)
pythonplot
x
plotlyjs
pgfplotsx
unicodeplots
inspectdr
gaston
pyplot
x
Versions
Plots.jl version: 1.37.2
Backend version (]st -m <backend(s)>):
(@v1.8) pkg> st -m PyPlot PythonPlot GR
Status `C:\Users\Shayan\.julia\environments\v1.8\Manifest.toml`
[28b8d3ca] GR v0.71.1
[d330b81b] PyPlot v2.11.0
[274fc56d] PythonPlot v1.0.0
Output of versioninfo():
julia>versioninfo()
Julia Version 1.8.3
Commit 0434deb161 (2022-11-1420:14 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU:8×Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
WORD_SIZE:64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
Threads:8 on 8 virtual cores
Environment:
JULIA_CONDAPKG_BACKEND = Null
JULIA_PYTHONCALL_EXE = C:\Users\Shayan\AppData\Local\Programs\Python\Python310\python.exe
JULIA_EDITOR = code
The text was updated successfully, but these errors were encountered:
shayandavoodii
changed the title
Saving shrinked version of color bar in heatmap leads to saving the unsshrinked version [BUG]
Saving shrinked version of color bar in heatmap leads to saving the unshrinked version [BUG]
Dec 19, 2022
I think the colorbar always takes up as much height as it can. You could achieve what you want by just reducing the height of the plot.
But for this issue specifically, I suppose the layout code is different for some reason depending on the display device? Not sure if that's a backend issue or a Plots issue.
I think the colorbar always takes up as much height as it can. You could achieve what you want by just reducing the height of the plot.
But for this issue specifically, I suppose the layout code is different for some reason depending on the display device? Not sure if that's a backend issue or a Plots issue.
Hi, thanks.
Issue solved by setting lims=(0,4) in the heatmap function.
Details
Plotting a heatmap plot:
Leads to
Then I tried to shrink the color bar length to fit the plot. So first, I began with changing the backend to
pyplot
andpythonplot
and moving thedpi
into theheatmap
function:And in the VSCode plot pane, it shows:
But the result of
savefig
is the same as unshrinked version!! :DBackends
This bug occurs on ( insert
x
below )Versions
Plots.jl version: 1.37.2
Backend version (
]st -m <backend(s)>
):Output of
versioninfo()
:The text was updated successfully, but these errors were encountered: