CairoMakie returning empty plots


I am new to julia, I want plot a simple scatterplot from a dataframe where the colors are coded as String7 hexadecimal code, a snapshot,

Row │ x      y      ncv_color 
     │ Int64  Int64  String7   
   1 │   120   4180  #005529
   2 │   120   3890  #004903
   3 │   110   4670  #004E66
   4 │   120   8270  #004A99
   5 │   120   9620  #005C5A

when I use the following code to draw a scatterplot, it works.

scatter(df.x, df.y)

Although when I use

scatter(df2.x, df2.y, color=:ncv_color)

I get FigureAxisPlot() as output and no plot is shown.

Any help would be appreciated.


Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD EPYC 7542 32-Core Processor
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)

Welcome @hiraksarkar
So far you didn’t get any response, probably because it would be much easier to look for a solution if you would provide some MWE (see Please read: make it easier to help you).
Despite that there are some obvious issues: you use df2 in the second scatter plot instead of df and strings as colors do probably not work per se, they need to be converted, and it should be color=df.ncv_color, or df2.color it df2 was intentional.

this works:

color = ["#005529", "#004903", "#004E66", "#004A99", "#005C5A"]
df = DataFrame(x = rand(5), y = rand(5), ncv_color = color)
scatter(df.x, df.y; color = df.ncv_color, markersize = 15)

yours should also.

1 Like

@oheil , @lazarusA Thanks a lot for the reply.

@oheil The df2 was a typo. So colors as strings seem to work as @lazarusA demonstrated. The problem in my code was String7 that does not work with Makie color plot.

The following conversion worked

df.ncv_color = convert(Vector{String}, df.ncv_color)

String works, String7 does not.

1 Like

df2 is a typo, should be df

1 Like