## How to plot the result of Grad function?

When I calculate the gradient of a two dimension function like $$r=\frac{1}{\sqrt{x^2+y^2}}$$ with the syntax of

h[x_,y_]:=Grad[1/r,{x,y}] 

and when I checked the result with

h[x,y][[1]] h[x,y][[2]] 

I got a right result of $$-\frac{x}{(\sqrt{x^2+y^2})^{-3/2}}$$ and $$-\frac{y}{(\sqrt{x^2+y^2})^{-3/2}}$$, respectively.

However, when I tried to plot the function with syntax of

VectorPlot[{h[x,y][[1]],h[x,y][[2]]},{x,0.1,0.3},{y,-0.3,0.3}] 

I found the value in y direction is 0, and I also confirmed with

Plot3D[h[x,y][[1]],{x,-0.3,0.3},{y,-0.3,0.3}] Plot3D[h[x,y][[2]],{x,-0.3,0.3},{y,-0.3,0.3}] 

and the results are that the first one has a proper plot while the second one shows the function value is 0.

Would anyone give me some clue that how this happened? Thank you and best regards!

## Is this a Lost Mine of Phandelver Plot Hole?

I’m DM’ing for the first time with a group playing for the first time (Table of Noob’s :p). In the 1st chapter of Lost Mine of Phandelver, the characters come across dead horses, are attacked by goblins, and discover a path into the woods. The campaign book says they “can easily steer the wagon away from the road and tie off the oxen while the group pursues the goblins“. This, to me, implied that the wagon couldn’t go down the path.

Fast forward a bit, at the end of the path is a cavern/goblin hideout, PC’s enter, kill goblins and bugbear leader (Klarg), yada yada yada. In Klarg’s lair, there are a bunch of supply crates, and the description says “the captured stores are bulky, and the characters will need a wagon to transport them“. They have a wagon, but apparently no way to get it to the cave.

The trail is 5 miles long, so carrying the crates back to the wagon is out. My solution was to retroactively say that when they entered the clearing where the cave is, they could see another, wider path leaving the clearing that has clearly been used for moving vehicles/supplies. This was met with dissent, as it was deemed “railroading” the story and not letting them discover a way themselves. So finally, 3 questions off this:

1. Is this actually a plot hole, or have I missed something?

2. Is the discovery/creation of the 2nd path both an appropriate solution, and one that a DM should make?

1. What other alternatives could there be for this situation?

I greatly appreciate any insight/help with this…

## How do I plan sessions that are still fun even if they don’t move the plot forward?

I’m fairly new to DMing, but I really enjoy it. My campaign is still pretty early in, and plot is moving forward pretty well; last session actually revealed a huge chuck of the relevant current events. Last session was also a nightmare; the entire party suddenly became hectic and chaotic (borderline murder-goblins). Next session is going to be pretty quiet in comparison; not really any new information, or any new goals (yet), and really, their characters are probably in trouble for causing several messes in town.

I’m not sure how to rectify this. How can I keep the players entertained while they’re not going anywhere or doing anything that progresses the plot? How do I make sure they’re having fun while the plot is at a standstill?

## how can I plot two variables (inside a definite integral) against each other

I want to plot x against y in this relation:

## How to super impose a curve onto a 2-D contour plot

I have created a smooth color gradient 2-D contour plot with existing compiled data. I have an x-axis, y-axis, and z-data contour plotted as a colormap. I have a single value of z-data that I want to plot as a curve onto the colormap.

x = 0.05:0.05:1; y = 0.0:0.05:1; [X, Y] = meshgrid(x, y); Z = [data] contourf(X, Y, Z); pcolor(X, Y, Z); shading interp title() xlabel() ylabel() colorbar 

## How to plot 3d surface graph for a tuple inside a list in Python?

I’ve data set as shown below. I need to have a surface plot with x, y and z values (j needs to be ignored). Each tuple inside the data list must represent a point in the surface plot.

For example, when plotting python must take (-1.0, -5.0, 0.0, 128.05219942419836) value and plot it and then go to the next tuple and so on. I get a graph with my attempt but it seems to be incorrect.

Could someone help me to find out the error?

import matplotlib.pyplot as plt import numpy as np   data_list = [(-1.0, -5.0, 0.0, 128.05219942419836), (-1.0, 5.0, -5.0, 1050.0514787687544), (-1.0, 5.0, 0.0, 787.8822046898542), (-1.0, 5.0, 5.0, 35.6         0, 22.371836318366924), (-6.0, -10.0, 5.0, 4.702288827001351), (4.0, -5.0, 0.0, 216.35187799230525), (4.0, 5.0, 0.0, 1970.733458386331)]  #My attempt #zipping data j, x, y, z = zip(*data_list)  z = tuple(map(float, z))    dim_of_z = np.shape(z)  X, Y = np.meshgrid(x, y) Z = np.reshape(z,(1,(dim_of_z[0])))   fig = plt.figure() ax = fig.add_subplot(111, projection='3d')  ax.plot_surface(X, Y, Z, rstride=1, cstride=1, linewidth=0.1)           plt.show() 

#https://stackoverflow.com/questions/21161884/plotting-a-3d-surface-from-a-list-of-tuples-in-matplotlib

## R plot text: How to add regular text prefix to polynomial rendered in exponent form (not ^)

I’m trying to add this text to a plot: “Model: y = 1 + 2x – 3x^2 + 4x^3” where actual exponents are rendered as such (no ^ chars). (See screenshot)

Below is repro code. The first text() call works fine (no prepended regular text), but the second does not (with prepended text). (Execute soTest() to repro.)

Any suggestions? I guess I don’t know which R keywords to search for to find a solution. Any help would be appreciated! (Please pardon the camel-casing, I’m writing a slide deck for an audience with at least a few non-R coders.)

evalPoly = function( x, coeff ) {     if ( length( coeff ) < 1 ) return( c(0) )        termSum <- 0     for ( i in 1:length(coeff) ) {         termSum <- termSum + coeff[i] * x^(i-1)     }     return( termSum ) }  soTest <- function() {     coeff <- c( 1, 2, -3, 4 )     x <- 1:8     y <- evalPoly( x, coeff )     plot( x, y )     text( 2, 1600, parse( text="1+2*x-3*x^2+4*x^3" ), adj=0 )     text( 2, 1400, parse( text="Model:  y = 1+2*x-3*x^2+4*x^3" ), adj=0 ) } 

## Parameterization of boundary curve in 3D Plot

I am considering a function of the form:

u0 = p[1](Q1[1] – K1)/(p[1] – K1 + Sqrt[(K1)^2 – m1^2](1 – 2*alpha));

with p[1],Q1[1], and m1 being constant (set p[1] = 1, Q1[1] = 1/2, m1 = 0.1). Therefore, i am considering u0 as a function of K1 and alpha. Due to physical restrictions, i want my u0 to be between the values 4/9 and 0.48, while K1 might be between 0.1 and 1/2 and alpha between 1/2 and 1. One can easily check that the domain for K1 and alpha are too large in order to guarantee that u0 lies between 4/9 and 0.48 by checking the equation above. Hence, i need to restrict alpha or K10 such that u0 always lies in my desired domain. A plot might be somewhat revealing:

Plot3D[u0Max3*0.48, {K1, 0.1, 1/2}, {alpha, 1/2, 1}, PlotRange -> {4/9, 0.48}];

Ultimately, i aim for integrating this volume with numerical procedures like NIntegrate or Vegas, but for this i need to state the domain of the variables. So i am looking for a way to get a functional dependence between alpha and K1 such that i can integrate this and obtain the correct volume.

## Custom plot markers in DistributionChart

I would like to use the ChartElementFunction option of DistributionChart to plot data with a custom style that includes custom plot markers, such as open circles. I am struggling with the scaling of the markers, though.

If I use Points as plot markers, everything is fine:

data = Table[RandomReal[i + {1, 3}, 10], {i, 5}];  cef1[{{xmin_, xmax_}, {ymin_,ymax_}}, data_, metadata_]:=     {Black, PointSize[Large], Point[{RandomReal[{xmin, xmax}], #}]& /@ data};  DistributionChart[data, ChartElementFunction -> cef1] 

If I use Circles, they are affected by the aspect ratio of the plot and shown as ellipses:

cef2[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] :=      {Black, Circle[{RandomReal[{xmin, xmax}], #}, 0.05] /@ data};  DistributionChart[data, ChartElementFunction -> cef2] 

Is there a way to get the scaling right, for example make the markers behave like PlotMarkers in ListPlot?

## How to scatter plot from matrix with many y-axes values for each x-axes value?

Consider matrix

A = {{0, 2.54343, 3.566, 4.2323, 2.3434}, {0.1, 6.432, 4.6465, 5.656,  1.34},  {0.2, 0.3423, 1.6342, 3.323, 2.04}}; 

X-axes values are 0, 0.1, 0.2.

Their are 4 y-axes values for each x-axes data point

How to plot this?

Naive use of

ListPlot[A] 

fails.