1

I'm trying to plot some data using Julia, but I'm quite new to Data visualisation in Julia. I have code that looks like this:

x_data = [5 10;
        15 20]

groupedbar( ["0.2", "0.8"], x_data, xlabel = "X-axis", 
    ylabel="Y-axis")

Each x-value (0.2 and 0.8) will have 2 bars each which are different colours. I am trying to create a legend for these colours.

I have tried the following code but it for some reason plots the data incorrectly (only plots the first 2 data points):

groupedbar( ["0.2", "0.8"], x_data, xlabel = "X-axis", 
    ylabel="Y-axis", group = ["Category 1", "Category 2"])

1 Answers1

0

Is this what you want?

groupedbar(["A", "A", "B", "B"], [4, 1, 2, 3], group = ["x", "y", "x", "y"])

(note that all three arguments have the same length)

Bogumił Kamiński
  • 66,844
  • 3
  • 80
  • 107
  • Visually that looks like what I want, however I don't understand the data you use here "1:10" and how do I rewrite my data to have that format? Also I still don't fully understand why the repeat function is necessary and why the value of 5 is chosen? Really appreciate your help with this. – React_validatorMan Jan 20 '23 at 13:19
  • I had to use some dummy data because you have not shared your data. I have edited the data to make it simpler. I hope now it will be clearer (now it is a single point per combination of group and level). – Bogumił Kamiński Jan 20 '23 at 13:26
  • Nevermind, after some more time tweaking I got what I needed. Thank you. – React_validatorMan Jan 20 '23 at 13:27
  • Just seen the edit as well, that also helps a lot thanks! – React_validatorMan Jan 20 '23 at 13:29