Change Default Point Size of geom_point in R

Nizamuddin Siddiqui
Updated on 06-Mar-2021 11:37:41

444 Views

To change the default point size of geom_point, we need to use update_geom_defaults function. Specifically, for the change of point size the syntax will be as follows −update_geom_defaults("point",list(size=”value”))Here, we can change the value according to our need.ExampleConsider the below data frame − Live Demox

Find Proportion of Each Value for Cross Tab in R

Nizamuddin Siddiqui
Updated on 06-Mar-2021 11:33:10

979 Views

To find the proportion of each value for a cross tab obtained from a data frame, we can use prop.table function. Suppose we have a data frame called df that contains three columns, two categorical say C1 and C2 and one numerical say Y then the cross tab will be created by using the command xtabs(Y~.,df). Now the proportion of each value can be found by using prop.table(xtabs(Y~.,df),1).Example1Consider the below data frame − Live Demof1

Change Point Size in geom_point Conditionally in R

Nizamuddin Siddiqui
Updated on 06-Mar-2021 11:24:20

2K+ Views

To change the point size in geom_point conditionally, we can define the condition in geom_point with aes and the size using scale_size_manual function of ggplot2 package. For example, if we have a data frame called df that contains two columns say x and y then the scatterplot with different size of points for x values greater than 5 and less than equal to 5 can be drawn by using the below command −ggplot(df, aes(x, y))+geom_point(aes(size=x>5))+scale_size_manual(values=c(4, 7))ExampleConsider the below data frame − Live Demox6))+scale_size_manual(values=c(4, 7)) OutputRead More

Create a List of Regression Models for Predefined Vectors in R

Nizamuddin Siddiqui
Updated on 06-Mar-2021 11:23:20

2K+ Views

To create a list of regression models for predefined vectors, we can create a blank list and then use the for loop to create the list of regression models. For example, if we have two vectors say x and y, and we want to create a list of regression model between x and y then we create a blank list using list() and perform for loop a particular number of times as shown in the below examples.Example1 Live Demox

Add Approximately Equal Sign in a Plot Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 06-Mar-2021 11:22:11

579 Views

To add approximately equal sign in a plot using ggplot2, we can use tilde sign twice as ~~ in geom_text function of ggplot2 package. For example, we can do this by using the following syntax geom_text(aes(label="NULL%~~%")). Check out the below example to understand how it works.ExampleConsider the below data frame − Live Demox

Word Dictionary Using Python Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:14:21

3K+ Views

In this article, we will create a GUI-based dictionary using PyDictionary and Tkinter Module.PyDictionary is a Python Module that helps to get meaning translations, antonyms and synonyms of words. It uses WordNet for getting meanings, Google for translations, and synonym.com for getting synonyms and antonyms. PyDictionary uses BeautifulSoup, Requests module as the dependencies.In order to create the application, we will first install these modules in our environment using pip install PyDictionaryAfter installing, we will create a tkinter frame and some other element.Example# Import Required Librares from tkinter import * from PyDictionary import PyDictionary # Create instances and objests dictionary ... Read More

Window Resizer Control Panel in Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:08:53

427 Views

In this article, we will create a GUI-based window resizer control panel that will have a pane to resize the window by its height or width.In order to create the application, we will first create a slider that will help to resize the window size. The sliders are available in the ttk library of tkinter. We will import “ttk” first. Then, we will launch a new window which needs to be resized.Let us first import all the required libraries in the notebook and design the control bars using sliders.Example# Import the required Libraries from tkinter import * from tkinter import ... Read More

Tearoff Attribute in Tkinter Menu

Dev Prakash Sharma
Updated on 06-Mar-2021 09:04:56

945 Views

Using Tkinter.Menu, we can create menus and submenus. Also, there are some other properties which are used with tkinter menus.Tearoff property makes the menus in the window as tearable. tearoff attribute accepts a Boolean value to separate the menu from the main window or the parent window. With tearoff attribute, we have two options, If tearoff=0, make the menu stick to the Window.If tearoff=1, it display a “----” empty dotted lines on the menus through which we can separate our menu from the window.Example#Importing the tkinter library from tkinter import * win= Tk() win.title("Tearoff Example") win.geometry("600x500") #Define a Function ... Read More

Tkinter Bell Method

Dev Prakash Sharma
Updated on 06-Mar-2021 09:02:27

731 Views

Tkinter bell() method produces the default event or dialogue sound of the system. This method can be invoked in the default window or frame. We can change the sound of the window by going to the system configuration.In this example, we will create a button that will make the default sound.Example#Import the library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the size of the window win.geometry("700x150") win.resizable(0, 0) #Define the Bell function def click():    win.bell() Button(win, text= "Click Me", command= click).pack(pady=20) win.mainloop()OutputRunning the above code will create ... Read More

Ratio Calculator GUI Using Tkinter

Dev Prakash Sharma
Updated on 06-Mar-2021 09:01:23

467 Views

In this article, we will see how to create a functional application that calculates the ratio. In order to make it fully functional, we will use SpinBox method that generally creates an ideal spinner for a value. This value can be modified using the spinner widget in the frame. Thus, a SpinBox object takes values in the range from minimum to maximum.First, we will create a tkinter frame inside which we will define some widgets.Examplefrom tkinter import * win = Tk() win.title("Ratio Calculator") win.geometry("600x500") win.resizable(0, 0) #Create text Label for Ratio Calculator label= Label(win, text="Ratio Calculator", font=('Times New ... Read More

Advertisements