Skip to content

Instantly share code, notes, and snippets.

@AnupJoseph
Created October 27, 2022 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnupJoseph/15cce9261b3dce63c7ab3effd92df92d to your computer and use it in GitHub Desktop.
Save AnupJoseph/15cce9261b3dce63c7ab3effd92df92d to your computer and use it in GitHub Desktop.
Countplot
Gadfly.with_theme(:dark) do # Dark theme cause dark theme looks great with pluto
set_default_plot_size(25cm ,15cm)
# Think if this as pandas value_counts function
value_counts = sort(countmap(dataset[!,4]),byvalue=true)
states = collect(keys(value_counts))
# Going to use a dotplot for the visual
# Using a log scale here as the graph's boring otherwise
count_plot = plot(
x=1:length(keys(value_counts)),
y=collect(values(value_counts)),
Scale.y_log10,
Scale.x_discrete(labels=i->length(states[i])<=15 ? states[i] : "$(states[i][1:15])..."),
Guide.xlabel("Countries"),
Geom.hair, # Hair for a thin bar
Geom.point # Dot to ensure that each are separately visible
)
# draw(SVG("kaggle_countplot.svg"),count_plot)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment