How to change the precision of ticks in julia plot - plot

I'm plotting in julia for the first time and have installed the Juno IDE. I'm plotting with Plots.jl and every time I plot, the y-axis tics have lots of decimals.
I've tried multiple backends, like GR, Plotly, PlotlyJS, but none have changed the behavior I'm seeing.
This is the code I have currently producing my results:
using Plots
gr()
x = 1:10; y = rand(10)
p = plot(x,y)
And the figure that's output:
https://github.com/bojohnson02/Random/blob/master/fig.pdf

That's a temporary bug caused by some changes to Showoff, the package that Plots uses to create the axis ticks. It should be fixed already, so updating your packages should work (]up). If it doesn't work yet, and you're in a hurry, installing master of the two packages should do the trick (] add Plots#master followed by ] add Showoff#master).

Related

`yaxp` is no longer working like it used to

When I teach histograms using R, I use the yaxp parameter to adjust the y-axis. Here is an example of the code:
hist(bookspending$'Dollars on books', yaxp = c(0,9,9))
This produces a histogram where the y-axis has tick marks at 0, at 9, and a tick mark at every integer in between. Here is a picture of it:
I'm using Rstudio version 1.4.1717 and R version 4.1.1. This has worked the past 4 years. This semester the yaxp parameter isn't working for some students. I replicated the problem using the web-based version of R. Using the same code, the yaxp parameter makes no changes to the histogram. Here is the picture:
Why does yaxp no longer work for the online version, but it works for my version? How do you adjust the y-axis without yaxp?
This happens because there was a change in the function graphics:::plot.hist in R version 4.2.0.
Previously, the part of the function that controlled the drawing of the axes was simply:
if (axes) {
axis(1, ...)
axis(2, ...)
}
But it has been changed to
if (axes) {
axis(1, ...)
yt <- axTicks(2)
if (freq && any(ni <- (yt%%1) != 0))
yt <- yt[!ni]
axis(2, at = yt, ...)
}
Which means that the y axis breaks are now decided solely by the output of the function call axTicks(2). Your yaxp argument is still passed to axis, but unfortunately, specifying at nullifies yaxp.
This is sort of mentioned in the CRAN R News, where it says:
hist.default() gains new fuzz argument, and the histogram plot method no longer uses fractional axis ticks when displaying counts ("Frequency").
So the reason for the change was to prevent fractional axis ticks, but a side effect of this was preventing users from specifying y axis breaks. The only work-around for now it would seem, would be to add the axes manually as suggested in the last set of comments.
You may wish to file this as a bug report, since it seems to me that it should be possible to specify axis breaks and disallow fractional breaks without much difficulty.

ggplot boxplot labels not showing

I am creating a boxplot and can get the plot to show, but the x and y axis ticks and labels do not show up. This occurs with my own data as well as with example data. Here is the example data (from http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/:
bp <- ggplot(PlantGrowth, aes(x=group, y=weight)) +
geom_boxplot()
bp
And the resulting figure
Setting the discrete x axis doesn't change anything either
bp + scale_x_discrete(limits=c("trt1","trt2","ctrl"))
results in changing the order of the boxplots but no labels show. Why aren't the ticks and labels showing up and how do I get them to show?
Question was solved in the comments by #chemdork123 but wanted to post the answer here to close the question. I uninstalled all of the packages but the base and recommended packages, following the instructions found here https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/. After uninstalling all packages, I reinstalled ggplot2 and the captions appeared. After reinstalling each previous problem one by one I learned ggtern was the issue here. Removing ggtern and reinstalling ggplot2 again fixed the issue and code runs perfectly.

ggplot: axes lines, values, and labels not plotting

I recently noticed that when I try plotting anything in ggplot2, both the x and y axes data (values, labels, lines, everything) are missing. I have tried to manually specify and enter the missing data using scale and theme commands, but ggplot still won't display the axes.
For example, the following simple code produces this plot on my computer:
ggplot(mpg, aes(x=class,y=hwy)) + geom_boxplot()
I have been using R and ggplot regularly for a few years and never encountered this problem until recently, but I don't know what computer/R/ggplot settings could have changed.
Interestingly, when I use base plotting functions there are no issues (both axes plot normally), so it seems like it's only an issue in ggplot.
E.g., the base code below produces this plot on my computer:
boxplot(mpg$hwy ~ mpg$class)
I have tried uninstalling and reinstalling ggplot multiple times to no avail.
Any advice for how to fix ggplot?
Thanks!

How to plot imagesc style heatmap with colorbar in julia

Here is what I tried.
-- Winston package: gives numerous errors saying "syntax deprecated" when trying to install or use. I tried doing Pkg.update() but this doesn't rid me of the errors. Despite the errors however Winston WILL plot a heatmap using the imagesc function just like matlab would... great ! but Winston does not have colorbars (?) :(
-- Plotly package: also gives numerous errors saying "syntax deprecated" when trying to install or use. I tried doing Pkg.update() but this doesn't rid me of the errors. Plotly shows in its documentation that it has colorbars but I cannot get anything working, presumably because of the deprecated syntax issue.
Would greatly appreciate any suggestions to plot imagesc style heatmaps in JULIA! I do not have access to matlab.
PyPlot is a good option for this:
using PyPlot
M = rand(10, 10)
pcolormesh(M)
colorbar()
[pcolor stands for "pseudo-color". Yes, it is a terrible name. And yes, it does come from MATLAB, like many other terrible names...]
There are three different relevant functions: pcolor, pcolormesh and imshow, which have different possibilities; see the Matplotlib documentation, e.g. http://matplotlib.org/examples/pylab_examples/pcolor_demo.html
(Note that the syntax in Julia can be slightly different.)
The Plots.jl package (https://github.com/tbreloff/Plots.jl) has a heatmap function that works with several different backends. It seems to me that this is the future of plotting in Julia, since you don't have to learn the intricacies of the different packages.
EDIT: Colour bars are indeed implemented in Plots.jl! See this issue: https://github.com/tbreloff/Plots.jl/issues/52
You can try the Vega.jl package. I recently built a stub of a heatmap functionality. The example works with julia 0.4+, but if you have any problems, please file an issue. I update the package pretty frequently.
http://johnmyleswhite.github.io/Vega.jl/heatmap.html
Pkg.add("Vega")
using Vega
x = Array(Int, 900)
y = Array(Int, 900)
color = Array(Float64, 900)
t = 0
for i in 1:30
for j in 1:30
t += 1
x[t] = i
y[t] = j
color[t] = rand()
end
end
hm = heatmap(x = x, y = y, color = color)

axis values doesnt display in figure while working in octave

Hi I am using GNU Octave, version 3.2.4.
While using plot or stem axis values are not shown in the figure window.
I am using GNUPLOT Version 4.4. When I plot something separately in gnuplot, it gives no error. For example in gnuplot:
set xrange [1:100];plot(x);
The above shows a plot with values on both axes, but the same isn't working in octave:
x=[1:100];plot(x);
This results on a figure window without any axis values.
I have tried all axis property options available in octave. Auto scaling works but values are still not displaying. Can anyone suggests how to correct this issue?

Resources