I want to create the earthquake graph with the look based on this reference Earthquake viz reference
Data
The data is look like this:
head(df)
|Date |Time.UTC|Latitude|Longitude|Depth|Depth.Type|Magnitude.Type|Magnitude|Region.Name |Last.Update |Eqid |X |color |
|----------|--------|--------|---------|-----|----------|--------------|---------|---------------------------|----------------|-------|---|-------|
|2023-02-10|06:11:56|-0.13 |123.12 |137 | | M |2.5 |SULAWESI, INDONESIA |2023-02-10 06:20|1221400| |#C4C4C4|
|2023-02-10|06:00:14|-1.79 |100.42 |27 | | M |2.9 |SOUTHERN SUMATRA, INDONESIA|2023-02-10 06:10|1221398| |#C4C4C4|
|2023-02-10|05:59:27|-1.31 |120.44 |10 | | M |2.7 |SULAWESI, INDONESIA |2023-02-10 06:05|1221396| |#C4C4C4|
|2023-02-10|05:26:25|-6.14 |104.72 |35 | | M |3.9 |SUNDA STRAIT, INDONESIA |2023-02-10 05:35|1221388| |#C4C4C4|
|2023-02-10|05:10:06|-8.08 |117.78 |18 | | M |2.8 |SUMBAWA REGION, INDONESIA |2023-02-10 05:15|1221377| |#C4C4C4|
|2023-02-10|04:55:01|0.99 |98.06 |25 | | M |3.3 |NIAS REGION, INDONESIA |2023-02-10 05:05|1221370| |#C4C4C4|
Code used
ggplot(df,aes(Date, Magnitude)) +
geom_point(data = df %>% filter(Magnitude > 5),
alpha = 0.9, size = 1.7, shape = 16, stroke = 0,
color = "#264653")+
geom_point(aes(color = Magnitude),
data = df %>% filter(Magnitude <= 5),
alpha = 1/20, size = 1.7, shape = 16, stroke = 0)
Output
Expectation
I'm expecting that the geom_points
for the data where its magnitude is below or equal to 5 to have grey color and use transparency gradient (higher magnitude, higher alpha, vice versa).
Other test
I tried to add
scale_color_gradient(low=alpha("#BFBFBF",0),high = alpha("#6B6B6B",0.9))
But the result have no transparency gradient as expected