I want to create a histogram serie. However, I also need to use weights (I cannot use seaborn).
I tried to use "for" to create this serie using:
list=range(28,37)
for i in list:
plt.hist(Base.iloc[:,i],weights=Base['weights']
But I got a Strange histogram:
I have 2 questions:
how do I create this serie; and,
what is this strange histogram?
for i in range (28,37)
plt.hist(Base.iloc[:,i],weights=Base['weights']
Related
R beginner here so sorry for the basic question... I have worked in class to draw some boxplots using the boxplot() function. As part of the assignment I've been asked to add data points to the boxplots. I can't seem to find an argument in the boxplot() function to do this...Is there another function I need to use? Thank you!
I recommend looking into ggplot2 package within R.
You can create multiple visualizations, including a boxplot with the data points shown. This is the ggplot code to do so:
library(ggplot2)
ggplot(df, aes(x=catvar, y=yvar)) +
geom_boxplot()+geom_dotplot(binaxis='y', stackdir='center', dotsize=1)
I have defined some plots which I now like to arrange using subplots. So I will pass an axis object to the plot definition and tell it to plot on that instead of making a new plot. However, to make this fool-proof I like to check that the passed object is actually of the right type, i.e. an axis.
When I make a subplot like so: f, ax = pyplot.subfigure(2,2) and inspect type(ax[1,1]) it returns matplotlib.axes._subplots.AxesSubplot, however I cannot use isinstance() to test against that value. What works is isinstace(ax[1,1],matplotlib.axes._subplots.Subplot). But I can also test against matplotlib.axes._subplots.Axes or matplotlib.axes._subplots.SubplotBase, all equate to True. I'm a bit confused by the ambiguity here. What is the correct way to test if something is an object one can plot on?
I've got a python script which generates graphs like the following both:
Now I'd like to initialize variables by their names:
sess.run(g1.initializer_op, feed_dict = {
g1.graph.get_tensor_by_name("sample_data:0"): [1,2,3,4]
})
Therefore, I need all variables to be named equally in all graph instances
However, at the moment each variable in the second graph gets a "_1" suffix.
How do I solve this problem?
Two different variables can't have the same name in tensorflow. That is why tensorflow adds "_1" to all variables which name already exists. If you want to use identical variables for all graphs, you have to create that variables in a tf.variable_scope and set reuse=True for each Graph you create after the first one.
I'm trying to fit my data using GNUplot. As it happens my data only has x-error bars. I heard version 5 is supposed to allow fitting using x errors only. How can one do this? I tried the following but as you can see I get errors that I cannot figure out:
gnuplot> fit f(x) "data1m" using 2:3:4 with xerrorbars via b,u,n
warning:
> Implied independent variable y not found in fit function.
> Assuming version 4 syntax with zerror in column 3 but no zerror keyword.
^
Need via and either parameter list or file
How can I resolve this?
It doesn't seem to work with x errors only, but you could use a very small constant y error.
Try fit f(x) "data1m" using 2:3:4:(1E-38) xyerrors via b,u,n
I am trying to create a histogram of numbers in an array. I am using Matlab to do this. I am connecting via ssh so I can only use Matlab in the terminal on my Linux computer. I am trying to create a histogram of the data in the array and save it as a .png. I know that in order for me to save this I need to use the print function. So far my attempt has been the following:
h=hist(array)
print(h,'-dpng','hist1.png')
which told me that there is no variable defined as -dpng but I thought that the point of that was to specify the file type.
Then I just deleted the -dpng and ran it as
print(h,'hist1.png')
to which it told me "Handle must be scalar, vector, or cell-array of vectors"
At this point I don't quite know what to do next. I would like for someone to help me figure out how to print this histogram to a .png file. Thank you.
hist does not return a figure handle, you could to do something similar to:
h = figure;
hist(array);
print(h, '-dpng', 'hist1.png');
to save the histogram.
By itself, the function hist(array) plots a histogram. If you assign the output to a variable, it returns the binned values of array, not the handle to your plot.
f = figure;
hist(array)
saveas(f,'hist.png')
you may would like to output the array to a csv file.
fid = fopen('file.csv','wt');
for i=1:size(arr)
fprintf(fid, '%s,%d,%d\n','element number' ,i ,arr(i));
end
fclose(fid);
See this link, you should be able to change the answers there to your needs: Outputing cell array to CSV file ( MATLAB )
You don't need to use figure handle unless you want to print not current figure. By default print uses gcf that returns handle for current figure.
So you just can do:
hist(array)
print('-dpng','hist1.png')
You got an error that there is no variable defined as -dpng probably because you forgot one quote symbol and used -dpng'.