problem in reordering the graph axis ggplot2, phyloseq - ggplot2

i have a shiny appp created which plots metagenome data using ggplot2, phyloseq and plotly with dplyr and tidyr. It creates pretty good stacked barplots and heatmaps only problem is it reorders sample names at x-axis e.g. 1-10 are arranged as 1,10,2,,5,6... how to correct that bug?

Related

Matplotlib 3D Scatter Plot

I would like to ask a question regarding Matplotlib 3D Scatter Plots
I have a data frame, consists of 3 columns and 55 rows.
I formatted it to a numpy array with
dataframe.to_numpy()
I have also some subset of my dataframe which should be coloured differently on the plot.
For example:
subset1
subset2
I would like plot my data frame with 3D Scatter Plots while coloring the points of different subsets differently.
I have tried bunch of methods but always getting error because of the shape of the subsets. Is there any more efficient way to do it?
I would appreciate for your suggestions.

Why stackplot and pandas area plot show stacked area so different?

The pandas dataframe df is like below from month Jan to Oct.
First graph was drawn by the command plt.stackplot(df.index,df, colors=pal, alpha=0.4) and second graph was drawn by command df.plot(kind='area', stacked=True, figsize=(18, 10)).
The second one is what I expected to see and I believe is also correct. But why the two graphs are so different from the same dataset? How can I fix the first command to correct the first graph?

How to make a Scatter Plot for a Dataset with 4 Attribtues and 5th attribute being the Cluster

I have a dataset which looks like this,
It has four attributes and the fifth column (which I added by myself) is the cluster of each row to which the row belongs.
I want to build something like a Scatter Plot for this dataset, but I am unable to do so. I have tried searching it up and the best I could find was this following question on Stackoverflow,
How to make a 4d plot with matplotlib using arbitrary data
Using this, I was able to make a Scatter Plot but it can only be done for three attributes while fourth attribute being the cluster of each row.
Can anyone help me figure out how would it be possible to do the same to make a Scatter Plot for a dataset similar to mine?
I would recommend something like seaborn's pairplot:
import seaborn as sns
sns.pairplot(df, hue="cluster")
See the images in the link, of what it looks like.
This creates several pairwise scatterplots instead of trying to make a 3D plot and arbitrarily flatten one of the dimensions.

Turn off x-axis marginal distribution axes on jointplot using seaborn package

There is a similar question here, however I fail to adapt the provided solutions to my case.
I want to have a jointplot with kind=hex while removing the marginal plot of the x-axis as it contains no information. In the linked question the suggestion is to use JointGrid directly, however Seaborn then seems to to be unable to draw the hexbin plot.
joint_kws = dict(gridsize=70)
g = sns.jointplot(data=all_data, x="Minute of Hour", y="Frequency", kind="hex", joint_kws=joint_kws)
plt.ylim([49.9, 50.1])
plt.xlim([0, 60])
g.ax_joint.axvline(x=30,ymin=49, ymax=51)
plt.show()
plt.close()
How to remove the margin plot over the x-axis?
Why is the vertical line not drawn?
Also is there a way to exchange the right margin to a plot which more clearly resembles the density?
edit: Here is a sample of the dataset (33kB). Read it with pd.read_pickle("./data.pickle")
I've been fiddling with an analog problem (using a scatterplot instead of the hexbin). In the end, the solution to your first point is awkwardly simple. Just add this line :
g.ax_marg_x.remove()
Regarding your second point, I've no clue as to why no line is plotted. But a workaround seems to be to use vlines instead :
g.ax_joint.vlines(x=30, ymin=49, ymax=51)
Concerning your last point, I'm afraid I haven't understood it. If you mean increasing/reducing the margin between the subplots, you can use the space argument stated in the doc.

Generating subplots of heatmaps in Julia-lang

I am trying to produce a figure/plot with more than a single heatmap (matrix with color shading according to the cell value). At the moment using Plots;
pyplot() and heatmap(mat) is enough to produce a heatmap.
It is not clear to me how to produce a single figure with more though. After looking at this page example subplots for how to use the layout, and then the example histogram, I cannot seem to produce working examples for the two together.
The question is how to produce a figure with two different matrices displayed via heatmap or some other function to do the same?
(as an extra side, could you also explain the context of the 'using' statement and how it relates to the 'backend'?)
The easiest way is to make a Vector of heatmaps, then plot those
using Plots
hms = [heatmap(randn(10,10)) for i in 1:16];
plot(hms..., layout = (4,4), colorbar = false)
The using statement calls the Plots library. The "backend" is another package, loaded by Plots, that does the actual plotting. Plots itself has no plotting capabilities - it translates the plot call to a plot call for the backend package.
Explanation of the code above:
Plotting with Plots is a two-step process. 1: plot generates a Plot object with all the information for the plot; 2: when a Plot object is returned to the console, it automatically calls julia´s display function, which then generates the plot. But you can do other things with the Plot object first, like put it in an array.
The heatmap call is a short form of plot(randn(10,10), seriestype = :heatmap), so it just creates a Plot object. 16 Plot objects are stored in the vector.
Passing a number of Plot objects to plot creates a new, larger Plot, with each of the incoming Plot objects as subplots. The splat operator ... simply passes each element of the Array{Plot} to plot as an individual argument.