Makie streamplot uniform log gridsize

Hello,

I am trying to create a streamplot in Makie with a log scale axis. I am trying to control the number of lines in the plot using the gridsize argument. However, because of my logarithmic scaling, I am having some trouble getting the plots to look nice. Here is a minimal (not) working example:

# Make fig
fig = Figure()
	
# Make axis
ax = Axis(fig[1, 1], xscale = log10)
	
# Some system of differential equation to plot
function mySystem(x)
	return Point2f((x[1] - 1)^2*x[2], x[2]*x[1])
end
	
# Add streamplot
streamplot!(
	ax, 
	mySystem,
	(1, 10), 
	(1, 10),
	gridsize = (20, 10),
	maxsteps = 10,
	stepsize = 0.01,
)
	
# Show plot
fig

This gives the following figure (granted this is not a very interesting example, but hopefully it illustrates the intention :slight_smile:):

Is there a way to specify somehow to use a logarithmic scale for the gridsize?

As you can see, the arrows are rather compressed to the right of the plot. I would like to have them spread out uniformly in space.

The quickest hack I could think of would be to rescale the equations directly and then change the tick labels, but would be a bit more convenient to have a control directly over the representation of the data.

Perhaps I am going about this wrong, as I am rather new to Makie! Feel free to correct me if there is a more standard way of making streamplots!

Thanks in advance!

I don’t think there’s a way to control the sampling space right now, but we should add that.

One thing you could do is evaluate the function in log-transformed space, as you already said, though your solution will be coarser the further left you go. Visually this shouldn’t be a problem, though, and there are ways to make this nicer in Makie without having to manage tick labels :slight_smile:

fig = Figure();
ax = Axis(fig[1, 1], xscale = log10)
# Some system of differential equation to plot
function mySystem(x)
	return Point2f((x[1] - 1)^2*x[2], x[2]*x[1])
end

function mySystemLogX(x)
	return Point2f(log10((x[1] - 1)^2*x[2]), x[2]*x[1])
end
	
# Add streamplot
plt = streamplot!(
	ax, 
	mySystemLogX,
	log10.((1, 10)), 
	(1, 10),
	gridsize = (20, 10),
	maxsteps = 10,
	stepsize = 0.01,
)

# Set the plot's nonlinear transform to `identity`, 
# since you've already transformed the data yourself
plt.transformation.transform_func[] = identity

# Show plot
fig

1 Like

Oh ok, thank you!