tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Linetype of legend entities not correct

Open Robinlovelace opened this issue 3 years ago • 0 comments

I'm not 100% sure this is a bug, and confident it will be fixed in v4.0.0 if it is, but thought it worth reporting my experience:

zone_cents = st_centroid(zones_od)
zone_cents_rail = zone_cents[desire_rail, ]
bb = tmaptools::bb(desire_rail, ext = 1.1)
desire_rail_plot = rbind(
  st_sf(data.frame(Geometry = "Desire line (original)"), geometry = desire_rail$geometry),
  st_sf(data.frame(Geometry = "Leg 1 (origin to station)"), geometry = desire_rail$leg_orig),
  st_sf(data.frame(Geometry = "Leg 2 (station to station)"), geometry = desire_rail$leg_via),
  st_sf(data.frame(Geometry = "Leg 3 (station to destination)"), geometry = desire_rail$leg_dest)
) 
desire_rail_plot = desire_rail_plot |> 
  mutate(lty = case_when(Geometry == "Desire line (original)" ~ 2, TRUE ~ 1))
# tmaptools::palette_explorer()
tm_shape(desire_rail_plot, bbox = bb) +
  tm_lines(col = "Geometry", palette = "Set2", lty = desire_rail_plot$lty) +
  tm_shape(bristol_stations) + tm_dots(col = "red") +
  tm_shape(zone_cents_rail) + tm_dots(col = "black")

Result, the lty values are not right, only the original desire lines are dotted in the map but not in the legend:

image

It seems that because the first 3 values of the lty column/vector are 2, the first 3 legend entries are dashed. Full reprex in commit below.

Robinlovelace avatar Aug 28 '22 19:08 Robinlovelace