Skip to content

Changing tick-values in raster-plot #1987

Answered by Fil
Hvass-Labs asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to keep data as an array of pixel colors, the best solution is to apply an affine transform on x and y:

Plot.plot({
  aspectRatio: 1,
  color: {label: "Elevation (m)", legend: true},
  x: {transform: d => d * 10 - 100},
  y: {transform: d => d * 10 + 223},
  marks: [
    Plot.raster(volcano.values, {width: volcano.width, height: volcano.height})
  ]
})

Otherwise you can see data as an array of samples with abstract positions and values, and use a spatial interpolator to fill the image; but it's not going to give the same image (for better or worse).

Plot.plot({
  aspectRatio: 1,
  color: {label: "Elevation (m)", legend: true},
  marks: [
    Plot.raster(volcano.values, {
   …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Hvass-Labs
Comment options

@Fil
Comment options

@Hvass-Labs
Comment options

@Fil
Comment options

@Hvass-Labs
Comment options

Answer selected by Hvass-Labs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants