UndefVarError: `colorbar` not defined while using Plots.jl

While using Plots.jl i am getting error UndefVarError: colorbar not defined
Please code below :point_right:

begin
	fig = plot(size=(300, 300))  # figsize=(20, 20)
	ax = fig[1]
	
	# Define colormap
	colormap = :jet
	
	# Set plot limits and aspect ratio
	xlims!(ax, (0, x_lim))
	ylims!(ax, (0, y_lim))
	aspect_ratio=print(ax)
	
	# Define color range for density plot
	vmin = 1e-8
	vmax = 1e-2
	
	# Create density plot
	print(size(rho[1,:,:] .* v_p[1,:,:]))
	density2 = heatmap!( rho[1,:,:] .* v_p[1,:,:], cbar=true, clim=(log(vmin), log(vmax)), xlabel="X", ylabel="Z", title="Density vs X-Z")
	
	# Create contour plot
	contour!( psi[1,:,:], levels=contour_levels, linecolor=:white, linewidth=4)
	
	# Add colorbar
	cbr = colorbar(density, label=L"\mathbf{\rm{log}_{10}(\rho{\rm v_p})}", 
	   ticks=[log10(vmin), 0, log10(vmax)], ticklabels=["$vmin", "1", "$vmax"])
	
	# Save the plot
	savefig("plot.png")
	@show density2
end

Why do you think this function should exist? Can you link to some documentation showing the usage?

In Subplot Attributes · Plots there is colorbar. What else should i use instead of colorbar?

That’s not a function but an attribute - i.e. plot(some_data; colorbar = some_colorbar)

1 Like

But i am using heatmap() and how can include it?