When I try to draw a map with a Hobo–Dyer projection, it told me:
Error in st_crs.character(x[[shape.id[masterID]]]$projection) : invalid crs: hd
Here is my code:
tm_shape(countries_spdf, projection = "hd") +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
What should I do?
I believe the projection feature of tm_shape has been changed to only take on integers representing the desired CRS. i.e. it still works with 4326, which is the most common one in the industry. However there is workaround using coord_map from ggplot library which I have included below:
tm_shape(countries_spdf, projection = 4326) +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
tm_shape(countries_spdf, projection = coord_map("hr")) +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
Hope this helps
Related
I have created an alluvial plot but, for visibility purposes I would like to move one lode in one of the axes: more specifically I would like the "NA" of the "Type of surgery" to be at the top so the last 4 axes are aligned.
This is the code I used on R:
aes(y = ID, axis1 = Reason, axis2 = Response, axis3=Type_of_surgery, axis4=Margins, axis5=RT_post_op, axis6=Chemo_post_op)) +
geom_alluvium(aes(fill = Type_of_surgery), width = 1/12,aes.bind = TRUE) +
geom_flow(aes.bind = TRUE) +
geom_stratum(width = 1/3, fill = "grey", color = "white") +
geom_label(stat = "stratum", aes(label = after_stat(stratum))) +
scale_x_discrete(limits = c("Reason", "Response","Type of surgery", "Margins","RT post op", "Chemo post-op"), expand = c(0.1,0.1)) +
scale_fill_brewer(type = "qual", palette = "Pastel1") +
ggtitle("TBC") ```
This is the plot I obtained:
[Alluvial plot][1]
[1]: https://i.stack.imgur.com/nDCIZ.png
I am beginning on the world of coding so any help would be most welcome,
Thank you all for your help,
JB
I'm trying to slice a part of this part, so that it matches the bottom part, and the method I'm trying is SubtractAsync.
When I do it however, the part gets sliced, but not so that the remaining part gets removed. Here's what I mean:
How do I edit my code to slice off the piece of the part?
My code:
local Brick = workspace.Brick
local Stack = Brick:Clone()
local TS = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, math.huge, true)
Stack.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + Brick.Size.Y, Brick.Position.Z - 55)
local tween = TS:Create(Stack, tweenInfo, {Position = Vector3.new(Stack.Position.X, Stack.Position.Y, Stack.Position.Z + (55 * 2))})
Stack.Parent = workspace
tween:Play()
game.ReplicatedStorage.PlaceDown.OnServerEvent:Connect(function()
tween:Pause()
local PartA = Instance.new("Part")
local PartB = Instance.new("Part")
PartA.Transparency = 1
PartB.Transparency = 1
PartA.Parent = workspace
PartB.Parent = workspace
PartA.Orientation = Vector3.new(-90, 0, 0)
PartB.Orientation = Vector3.new(-90, 0, 0)
PartA.Size = Vector3.new(15, 0.051, 15)
PartB.Size = Vector3.new(15, 0.051, 15)
PartA.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + 2.5, Brick.Position.Z - (Brick.Size.Z/2))
PartB.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + 2.5, Brick.Position.Z + (Brick.Size.Z/2))
PartA.Anchored = true
PartB.Anchored = true
local SlicedStack = Stack:SubtractAsync({PartA, PartB})
SlicedStack.Position = Stack.Position
SlicedStack.Parent = workspace
Stack:Destroy()
PartA:Destroy()
PartB:Destroy()
end)
Pinescript array, checking to see if array size is minimal needed, yet it is display this error enter image description here
Here is the code I am refering:
if confirmedTriangle and array.size(triangle_price)>4 and array.size(triangle_index)>4
for i = 0 to 3
//Slope
xIndexDis = array.get(triangle_index, 0) - array.get(triangle_index, 4)// : na
yPriceDis = array.get(triangle_price, 0) - array.get(triangle_price, 4)// : na
xIndexDis2 = array.get(triangle_index, 3) - array.get(triangle_index, 1)// : na
yPriceDis2 = array.get(triangle_price, 3) - array.get(triangle_price, 1)// : na
m = yPriceDis / xIndexDis //Gradient for bottom line
m2 = yPriceDis2 / xIndexDis2 // Gradient for top line
x1 = array.get(triangle_index, i)-testLength
y1 = array.get(triangle_price, i)
x2 = array.get(triangle_index, i+1)-testLength
y2 = array.get(triangle_price, i+1)
array.push(tri_array, line.new(x1,y1,x2,y2, color=color.white))
xa1 = array.get(triangle_index,4)
xa2 = array.get(triangle_index,0)
xb1 = array.get(triangle_index,3)
xb2 = array.get(triangle_index,1)
ya1 = array.get(triangle_price,4)
ya2 = array.get(triangle_price,0)
yb1 = array.get(triangle_price,3)
yb2 = array.get(triangle_price,1)
label.new(bar_index, high+atr, text="Xa1 = " + str.tostring(xa1) + " / Ya1 = " + str.tostring(ya1) + "\n Xa2 = " + str.tostring(xa2) + " / Ya2 = " + str.tostring(ya2) + "\nXb1 = " + str.tostring(xb1) + " / Yb1 = " + str.tostring(yb1) + "\n Xb2 = " + str.tostring(xb2) + " / Yb2 = " + str.tostring(yb2))
I don't get any errors on sometimeframes but the majority do present the same error,
Found the issues,
I assigned array.size(triangle_price) to a variable
e.g. arraySize = array.size(triangle_price)
In confirmedTriangle I was checking if arraySize>4, but the array size had been changed since that check
Simple fix was just to remove "arraySize = array.size(triangle_price)" and use array.size(triangle_price) in each check
I'm trying to make a map of Europe using tmap and the eurostat package.
I want to add a compass and a scale bar to the map. However they don't appear inside the graph, but outside of the map, at the bottom. Does anyone know what I'm doing wrong? I want the compass at the left top of the map, and the scale bar at the right bottom.
countries = gisco_get_countries(
year = "2016",
epsg = "3035",
resolution = "3"
)
br = c(0,40,50,65,80,150)
tm_shape(countries, bbox = c(23, 14, 74, 55) * 10e4) +
tm_fill("#E0E0E0") +
tm_shape(nuts2.sf) +
tm_fill(
"fatal_inj_30day",
breaks = br,
style = "fixed",
palette = "Blues",
alpha = .7,
title = "Fatalities per million inhabitants \n(2018-2019)"
) +
tm_compass(position = c("left","top")) +
tm_scale_bar(position = c("right","bottom")) +
tm_shape(countries) +
tm_borders(lwd = .25) +
tm_layout(
bg.color = "#F2F2F2",
outer.bg.color = "white",
legend.bg.color = "white",
legend.frame = "black",
legend.title.size = 0.8,
inner.margins = c(0, 0, 0, 0),
outer.margins = c(0, 0, 0, 0),
frame = TRUE,
frame.lwd = 0,
attr.outside = TRUE,
legend.position = c("right", "top"),
main.title = "Note: regions with 10 fatalities or less are not included in the Figure",
main.title.position = "left",
main.title.size = 0.7
)
Is there a way of saving the movies produced with ffmmeg_renderer or av_renderer as separate files? I always get theme embedded as data in the html file.
Using the example from #Roman I would use library("av") instead:
p <- ggplot(airquality, aes(Day, Temp)) +
geom_line(size = 2, colour = 'steelblue') +
transition_states(Month, 4, 1) +
shadow_mark(size = 1, colour = 'grey')
b <- animate(p, duration = 20, fps = 20, renderer = av_renderer())
anim_save("output.mp4", b)
Since you didn't provide a reproducible example:
p <- ggplot(airquality, aes(Day, Temp)) +
geom_line(size = 2, colour = 'steelblue') +
transition_states(Month, 4, 1) +
shadow_mark(size = 1, colour = 'grey')
a <- animate(p, renderer = ffmpeg_renderer())
anim_save("animation.mp4", a)