# Makie streamplot uniform log gridsize

**URL:** <https://discourse.julialang.org/t/makie-streamplot-uniform-log-gridsize/119079>\
**Category:** Visualization\
**Tags:** makie, cairomakie\
**Created:** [September 5, 2024, 4:17pm UTC](https://discourse.julialang.org/t/makie-streamplot-uniform-log-gridsize/119079 "2024-09-05T16:17:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmdenis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmdenis/32/211517_2.png) [@cmdenis](https://discourse.julialang.org/u/cmdenis)\
**Post date:** [September 5, 2024, 4:17pm UTC](https://discourse.julialang.org/t/makie-streamplot-uniform-log-gridsize/119079/1 "2024-09-05T16:17:56Z")

</div>

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:

```julia
# 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 🙂):

 ![Capture d’écran, le 2024-09-05 à 12.01.57](https://global.discourse-cdn.com/julialang/original/3X/3/4/3492cf011c8ad076e2e0699cb2a6bb8febefd86b.png)

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!

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [September 5, 2024, 9:25pm UTC](https://discourse.julialang.org/t/makie-streamplot-uniform-log-gridsize/119079/2 "2024-09-05T21:25:55Z")

</div>

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 🙂

```julia
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

```

 ![download](https://global.discourse-cdn.com/julialang/original/3X/a/d/ad09ffcf2b909ef60e73ade1a176245b73a2df3c.png)

---

<div class="post-metadata">

**Author:** ![cmdenis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmdenis/32/211517_2.png) [@cmdenis](https://discourse.julialang.org/u/cmdenis)\
**Post date:** [September 9, 2024, 2:12pm UTC](https://discourse.julialang.org/t/makie-streamplot-uniform-log-gridsize/119079/3 "2024-09-09T14:12:25Z")

</div>

Oh ok, thank you!
