I am trying to plot a network of my ASVs using phyloseq using the plot_net function like so:
set.seed(711L) plot_net(Alaw_merged_30, distance = "bray", type = "taxa",maxdist = 0.7, color="Kingdom", point_label="Genus", laymeth = "auto", cex_val = 2)
My labels looked so small on my plot that I tried tried cex_val = 2 from the NeuralNetTools package but I keep getting this error:
Error in plot_net(Alaw_merged_30, distance = "bray", type = "taxa", maxdist = 0.7, :
unused argument (cex_val = 2)
Any help would be highly appreciated because my labels are so small on my plot currently!
Related
I'm relatively new to R, and I'm using the visreg package to plot a model. I can't figure out how to make that the points of the graph include a color of one of the considered factors ("Site").
enter image description here
My code is:
print(visreg(modeloSeleccionado, xvar = "Season", ylab = varList[k] , by = "Site", gg=TRUE, overlay=FALSE, points.par=list(size=2, alpha=1), jitter=TRUE))
Thanks!
I'm trying to decipher how to troubleshoot why I have an error in my code.
Basically, I have a JPG image and I need to segment it through using thresholds on the three RGB channels.
This is my code:
img = cv2.imread('sample.jpg')
img = np.asarray(img)
img = img[:,:,0:3]
plt.imshow(img)
plt.show()
img_gray = rgb2gray(img)
img_gray = np.around(img_gray)
img_gray = img_gray.astype(int)
img_gray
histogram2, bins2 = np.histogram(img_gray, bins=range(255))
plt.bar(bins2[1:], histogram2)
plt.show()
img_select = np.where((img_gray[:,:,0]<150) & (img_gray[:,:,1]>70) & (img_gray[:,:,2]<90), 1, 0)
plt.imshow(img_select, cmap = 'gray')
plt.show()
The error is at the img_select part. I'm given this error:
"too many indices for array"
Can someone help me troubleshoot this?
Here is a code snippet
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col = 'time')
g = g.map(plt.hist, "tip")
with the following output
I want to introduce despine offset to these plots while keeping the rest unchanged. Therefore, I inserted the despine function in the existing code:
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col = 'time')
g.despine(offset=10)
g = g.map(plt.hist, "tip")
which results in the following plots
As a result, the offset is applied to the axes. However, the ytick labels on the right plot are back, which I don't want.
Could anyone help me on this?
To remove the yaxis tick labels, you can use the code below:
The libs:
import seaborn as sns
sns.set_style('ticks')
The adjusted code:
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col = 'time')
g.despine(offset=10)
g = g.map(plt.hist, "tip")
# IMPORTANT: I assume that you use colwrap=None in FacetGrid constructor
# loop over the non-left axes:
for ax in g.axes[:, 1:].flat:
# get the yticklabels from the axis and set visibility to False
for label in ax.get_yticklabels():
label.set_visible(False)
ax.yaxis.offsetText.set_visible(False)
A bit more general, image you now have a 2x2 FacetGrid, you want to despine with an offset, but the x- and yticklabels return:
Remove them all using this code:
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col = 'time', row='sex')
g.despine(offset=10)
g = g.map(plt.hist, "tip")
# IMPORTANT: I assume that you use colwrap=None in FacetGrid constructor
# loop over the non-left axes:
for ax in g.axes[:, 1:].flat:
# get the yticklabels from the axis and set visibility to False
for label in ax.get_yticklabels():
label.set_visible(False)
ax.yaxis.offsetText.set_visible(False)
# loop over the top axes:
for ax in g.axes[:-1, :].flat:
# get the xticklabels from the axis and set visibility to False
for label in ax.get_xticklabels():
label.set_visible(False)
ax.xaxis.offsetText.set_visible(False)
UPDATE:
for completeness, mwaskom (ref to github issue) gave an explanation why this issue is occuring:
So this happens because matplotlib calls axis.reset_ticks() internally when moving the spine. Otherwise, the spine gets moved but the ticks stay in the same place. It's not configurable in matplotlib and, even if it were, I don't know if there is a public API for moving individual ticks. Unfortunately I think you'll have to remove the tick labels yourself after offsetting the spines.
I have image of the city, how i can get longitude/latitude for the points that i add to the image if i know 3 points like
Point1XRelative = "-18340651.0304568";
Point1YRelative = "14945227.3984772";
Point2XRelative = "-3960915.94162438";
Point2YRelative = "-7933119.6827411";
Point3XRelative = "4901426.10152285";
Point3YRelative = "13585796.8781726";
Point1XWorld = "53.1186547";
Point1YWorld = "29.2392344";
Point2XWorld = "52.6341388";
Point2YWorld = "29.7438198";
Point3XWorld = "53.0900105";
Point3YWorld = "30.0548051";
I have algrithm that can convert only for the plane and when i convert from the long/lat to x y they converts with offset.
Please advice me how i can resolve this problem.
It also depends on the zoom level. I think you will find what you need here.
It's a pretty self-explanatory question.
I am curious as to why there is no built-in function to create gradients. The only way I found to "fake it" is to create a series of lines or rectangles each with a unique color calculated with b.lerpColor.
I saw that the InDesign Object Model has of course the gradient class but I don't know how to access it using basiljs.
Maybe if someone could show me? Many thanks.
Check out this reference http://jongware.mit.edu/idcs6js/pc_Gradient.html
And try it like this:
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
function draw() {
var d = b.doc();
var r = b.rect(0, 0, b.width, b.height);
var myGrad = d.gradients.add({
name: "Col " + (parseInt(Math.random() * 10000)),
type: GradientType.linear
});
myGrad.gradientStops[0].properties = {
stopColor: d.colors.item(2),
location: Math.random() * 50
};
myGrad.gradientStops[1].properties = {
stopColor: d.colors.item(4),
location: 50 + Math.random() * 50
};
r.fillColor = myGrad;
// to set the fill of the gradient use the following line
r.gradientFillAngle = 50;//b.random(-180,180);
}
b.go();
The script creates a new gradient swatch every time you run it.
edit:added gradientFillAngle
Take a look here.
gradientFillAngle number r/w The angle of a linear gradient applied to the fill of the Rectangle. (Range: -180 to 180)