I have a density plot using ggplot and I have a mathematical function I want to add on the graph using +annotate() or something similar, but I am not sure how to do this.
The symbol I want in latex code is:
$f_{\epsilon}(|R_{i}|)$
Thanks for any help :)
try this,
# install.packages("latex2exp")
library(latex2exp)
test <- TeX("$f_{\\epsilon}(|R_{i}|)$")
library(grid)
grid.newpage()
grid.text(test, gp = gpar(cex=4))
Related
Is there any way to change legends/axis labels/tick marks in the plot( ) function for visualising model predictions in ggeffects? I can't find any mention of this in the function documentation, but it seems like such a bizarre thing to leave out ... ?
Thanks to user teunbrand - I hadn't realised you could add additional elements to ggeffects::plot() using as you would in ggplot( ) - adding + labs(title = "New title") etc worked!
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.
I am trying to remove all the labels from an mplfinance plot.
Using empty spaces on y axis still leaves the scaling label and I can't seem to reove the x labeling at all.
Appreciate if anyone knew how to do this.
Trying to achieve:
Current:
code:
import mplfinance as mpf
mpf.plot(data[i-50:i], type='candle',volume=True, mav=(7,12), style='yahoo', figratio = (3.12,3.12))
The latest version of mplfinance (0.12.5a3) has a new kwarg axisoff=True will remove all labels and axis lines.
It depends on what is the code.
You can try:
plt.set_xlabel("")
or could you please provide an example, that will be really helpful.
Thanks
I generated a clustermap using seaborn.clustermap. I wanted to show the row_colors option to highlight some clusters but this is the result I got:
clustermap with missing row_colors
Here you can find my code:
pal = sns.light_palette('red', np.unique(labels).size)
lut = dict(zip(np.unique(labels), pal))
row_colors = pd.Series(labels, name='clusters').map(lut)
sns.clustermap(my_data, method='ward', robust=True, row_colors=row_colors)
However if I run the example from the seaborn documentation I don't have any problem:
enter image description here
iris = sns.load_dataset("iris")
species = iris.pop("species")
lut = dict(zip(species.unique(), "rbg"))
row_colors = species.map(lut)
g = sns.clustermap(iris, row_colors=row_colors)
Why does the highlighting not work in my code?
Thank you very much for you answer error. I found out the problem. I have a MultiIndex dataframe and for some reason it doesn't plot the row_color. Actually this is the only difference with the iris example code.
And I just fixed the problem doing this:
sns.clustermap(my_data.reset_index(drop=True), method='ward', robust=True, row_colors=row_colors)
and now it works:
enter image description here
I don't know whether this can be considered as a bug but it looks like.
Perhaps that can help to fix it.
I am using Julia 0.5 and the latest version of PyPlot.
I am printing an 2D-Array using plot.pcolorand it works pretty good. But now I have data that needs a logarithmic scaling. I searched on the web and what I found was an example using
plt.pcolor(X, Y, Z1, norm=LogNorm(vmin=Z1.min(), vmax=Z1.max()), cmap='PuBu_r')
But since LogNorm seems to be a python function ist doesn't work in Julia. Does anyone have an idea what I can hand over to norm=to get a logarithmic scaling?
An example would be:
using PyPlot
A = rand(20,20)
figure()
PyPlot.pcolor(A, cmap="PuBu_r")
colorbar()
Matplotlib fields and methods can be accessed using the
matplotlib[:colors][:LogNorm]
syntax (i.e. for the corresponding matplotlib.colors.LogNorm object).
UPDATE: Thank you for your mwe. Based on that example, I managed to make it work like this:
PyPlot.pcolor(A, norm=matplotlib[:colors][:LogNorm](vmin=minimum(A), vmax=maximum(A)), cmap="PuBu_r")