Reputation: 151
I have a problem using the barplot function to Print a histogram. Every time I call I get the following error. I have checked the functions, but I do not see any errors. I put the function a data.frame input sample, the error and giving me an example of a result. Is there any other way to make histograms as the image?
It's funny because sometimes the function gives the result but other fails giving the error
function:
HIST_EPC_list<-function(DF_TAG_PHASE_EPC_counter){
barplot(DF_TAG_PHASE_EPC_counter$Num_EPC, names.arg = DF_TAG_PHASE_EPC_counter$Tag_PHASE, xlab = "Tag_PHASE", ylab = "Num_EPC", main="Histograma Num tags/PHASE:", width=10)
}
data.frame example: DF_TAG_PHASE_EPC_counter
Tag_PHASE Num_EPC
1 123.0 1
2 75.0 1
3 78.0 1
4 81.0 2
5 84.0 1
6 87.0 1
7 90.0 2
8 98.0 1
Error:
Error in plot.new() : figure margins too large
Called from: barplot(DF_TAG_RSSI_EPC_counter$Num_EPC, names.arg = DF_TAG_RSSI_EPC_counter$Tag_RSSI,
xlab = "Tag_RSSI", ylab = "Num_EPC", main = "Histograma Num tags/RSSI:",
width = 10)
Upvotes: 0
Views: 191
Reputation: 12401
The error "figure margins too large" comes from the fact you are trying to plot a too large graphics compared to the size of the plot frame.
It can happen for instance in RStudio when the plot zone is small.
You can try these these things:
x11()
command before plotting (it creates a new plot window)par(mar=...)
function to reduce the margins in your plot. For example, try par(mar=c(0.1,0.1,0.1,0.1)
(see ?par
)Upvotes: 1