0

I want to plot something with doulble x ticks labels one for the item name and other for the purchase month

Month Item Price
Feb Tomatoe 15
Feb Cockies 10
Feb Juice 20
Feb Orange 13
Mar Cake 11
Mar Potato 30
Mar Juice 13

I tried using twiny() but I want the labels on the same side. Excel Pivot Chart does the work but the performance is very low with huge amount of data.

Pivot Chart in Excel

  • Welcome to Stackoverflow! 1. Could you please include your pivot chart in the question? so in the event the image url is broken, other users can still benefit from your question. 2. What have you tried so far to solve your question and how much data have you got, how long does it take (to relatively say slow)? 3. Do you want to use Excel or Julia or use Excel in Julia? – bonCodigo Apr 29 '23 at 06:49
  • concatenate Month & Item? that would give one label. – Solar Mike Apr 29 '23 at 09:30

2 Answers2

2

using StatisticalGraphics.jl

using StatisticalGraphics, InMemoryDatasets
ds=Dataset(values = [15, 10, 20, 13, 11, 30, 13],
item = ["tomato", "cookies", "juice", "orange", "cake", "potato", "juice"],
Month = ["Feb", "Feb","Feb","Feb","Mar","Mar","Mar"])

sgplot(gatherby(ds,:Month), 
                             Bar(x=:item,response=:values),
                             layout=:row,
                             linkaxis=:y,
                             proportional=true,
                             headerorient=:bottom,
                             headercolname=false,
                             headeroffset=30,
                             panelborder=false,
                             columnspace=0,
                             xaxis=Axis(title=""),
                             yaxis=Axis(title="Total")
  )

enter image description here

giantmoa
  • 327
  • 5
1

You can use groupedbar() from StatsPlots to get something like that:

using StatsPlots

values = [15, 10, 20, 13, 11, 30, 13]
item = ["tomato", "cookies", "juice", "orange", "cake", "potato", "juice"]
Month = ["Feb", "Feb","Feb","Feb","Mar","Mar","Mar"]

groupedbar(item, values, group = Month)