I'm trying to combine VectorPlot and DensityPlot on the same graph. So I have:

p1=VectorPlot[function1, {x,a,b}, {y,a,b}, PlotLabel -> "vectors function1"  , VectorPoints -> Fine, VectorStyle -> Black, AxesLabel -> {"x", "y"}]


p2 = DensityPlot[function2, {x, a, b}, {y, a, b}, PlotLabel -> "density function2"  , PlotLegends -> Automatic, ColorFunction -> "TemperatureMap"]

and in order to combine them I used

plot1 = Show[{p2, p1}, PlotLabel -> "function1 and function2"]

a and b are constants I set at the beginning of the code. Now, the problem is that in all of the graphs the axes labels is not shown. even when I'm trying to add it to the Show function it shows the graph without the axes labels. I have another regular Plot in my code and there the axes label works fine.

Also, it seems that LegendLabel is not working. When I'm adding it to densityplot the code doesn't recognize that function. Also when I'm trying to add it to Show, error appears:

OptionValue: Unknown option LegendLabel for Graphics.

Is there anything I can do?

  • 1
    $\begingroup$ By default, VectorPlot (and DensityPlot) use Frame and FrameLabel instead of Axes and AxesLabel. That's why the axis labels aren't showing up. As for LegendLabel, it's an option to BarLegend, so you want to use PlotLegends -> BarLegend[Automatic, LegendLabel -> "label"]. $\endgroup$ Jan 15 at 16:16
  • 1
    $\begingroup$ Also, the function VectorDensityPlot will allow you to do this all at once if you're interested. $\endgroup$ Jan 15 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.