# Put all names on bar chart

**URL:** https://discourse.julialang.org/t/put-all-names-on-bar-chart/63191
**Category:** Visualization
**Tags:** bar, plot
**Created:** [June 19, 2021, 6:13pm UTC](https://discourse.julialang.org/t/put-all-names-on-bar-chart/63191 "2021-06-19T18:13:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Paolo\_Jara](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paolo_jara/32/25685_2.png) [@Paolo\_Jara](https://discourse.julialang.org/u/Paolo_Jara)
#### Post date: [June 19, 2021, 6:13pm UTC](https://discourse.julialang.org/t/put-all-names-on-bar-chart/63191/1 "2021-06-19T18:13:58Z")

</div>

Hello, I am making a bar graph of the annual income for districts within each department. I have two problems, (i) when I make the bar graph not all the names of the districts appear and (ii) is there a format so that it does not appear on the x axis :x10 ^ 5 ?

I leave the code with a simulated data.

```plaintext
begin
	cantidad=1000
	data_1=DataFrame(
		distrito=[randstring(4) for i=1:cantidad],
		departamento=["Departamento_$i" for i in rand(1:24,cantidad)],
		ingreso=[1000000*rand() for i=1:cantidad]
	)
end

begin
	depa_1 = unique(data_1.departamento)
	se_1=depa_1.=>depa_1
	md" $(@bind depa_elegido Select(se_1))"
end

begin
	data_2=filter(row ->row.departamento==depa_elegido, data_1);
	sort!(data_2, [:ingreso]);
end;

begin
	plot(data_2.distrito, data_2.ingreso, legend=:false, orientation=:h, seriestype=:bar)
	title!("Departamento de $depa_elegido")
	xticks!(LinRange(0, maximum(data_2.ingreso), 4))
	xlims!(0, maximum(data_2.ingreso))
end

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/2/527a46772d1d3422c9557eb40cc7416bbaa14b4d.png)

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [June 19, 2021, 11:20pm UTC](https://discourse.julialang.org/t/put-all-names-on-bar-chart/63191/2 "2021-06-19T23:20:08Z")

</div>

Check the following code (stripped out the notebook GUI stuff):

```julia
using Printf, DataFrames, Plots; gr(dpi=300)

cantidad = 1000
data_1 = DataFrame(
	distrito=[randstring(4) for i=1:cantidad],
	departamento=["Departamento_$i" for i in rand(1:24,cantidad)],
	ingreso=[1000000*rand() for i=1:cantidad] )
depa_1 = unique(data_1.departamento)
se_1 = depa_1.=>depa_1
depa_elegido = "Departamento_3"
data_2 = filter(row ->row.departamento==depa_elegido, data_1)
sort!(data_2, [:ingreso])

ny = length(data_2.distrito)
plot(data_2.distrito, data_2.ingreso, legend=:false, orientation=:h, seriestype=:bar)
yticks!(0.5:ny-0.5,data_2.distrito,ytickfontsize=4)
title!("Departamento de $depa_elegido")
x = LinRange(0, maximum(data_2.ingreso), 4)
str = [@sprintf("%i", xi) for xi in x]
xticks!(x,str, xlims=extrema(x),tickdir=:out,xtickfontsize=4)

```

 ![Plots_gr_barplot_xyticks](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e5f3c5ce99e14556b82eef6c3f11bb112f9fa5b.png)
