0
library(arules)
library(arulesViz)
library(RColorBrewer)

trans = read.transactions("https://raw.githubusercontent.com/tempAcccc/temRepo/main/TempFile.csv",format="basket", sep = ",",cols = c(1))
rule1 <- apriori(trans, parameter = list(support = 0.004,conf=0.05,target="rules"))
plot(rule1, measure=c("support", "confidence"),shading="order",col = brewer.pal(4,"Spectral"),main="Rules with Min_sup=0.004 and Min_conf=0.05")

This code generates this graph.
I want to change the part where it says order to "iterations" how can I do this?

thuettel
  • 165
  • 1
  • 11
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick May 02 '21 at 02:50
  • @MrFlick I have added the dataframe so that you can reproduce the results. – SuchAbsurdity May 02 '21 at 03:09
  • You should name required packages if you work with functions outside base R. Also, for me `read.transactions()` did not work with reading the DF from the environment. I had to read the file from source directly. I edited both in your post. Although the documentation of `arulesViz` says `In addition to using order for shading, we also give the plot a different title (main). Othercontrol options includingpch(best with filled symbols: 20–25),cex,xlimandylimareavailable and work in the usual way expected by R-users.` it seems to me like a change of legend labels is not possible. – thuettel May 02 '21 at 08:40

1 Answers1

1

The legend in the default plot is fixed and cannot be changed. You can use ggplot2 as the engine (requires the latest version of arulesViz). This way you can use all ggplot functions to overwrite parts of the plot. Here is an example

library(ggplot2)
plot(rule1, measure=c("support", "confidence"), shading="order", engine = "ggplot") + 
   ggtitle("Rules with Min_sup=0.004 and Min_conf=0.05") + 
   labs(color = "Rule length") + 
   scale_color_discrete(type = brewer.pal(4,"Spectral"))
Michael Hahsler
  • 2,965
  • 1
  • 12
  • 16