Trending March 2024 # Creating A Scrolling Background In Pygame # Suggested April 2024 # Top 9 Popular

You are reading the article Creating A Scrolling Background In Pygame updated in March 2024 on the website Moimoishop.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested April 2024 Creating A Scrolling Background In Pygame

Pygame is a popular Python library used for building games and multimedia applications. One of the most important aspects of game development is the ability to create scrolling backgrounds. In this article, we will cover the essential steps for creating a scrolling background in Pygame. We will also provide real-world examples and code snippets to help you understand the concepts better.

Other libraries which can also be used for game development in python −

Arcade − Arcade is a modern, easy-to-use library for creating 2D arcade-style games. It is designed to be easy to learn and use, and provides a range of features, including graphics, sound, and input handling.

PyOpenGL − PyOpenGL is a Python wrapper for the OpenGL 3D graphics library. It provides a range of features for creating 3D games, including graphics, lighting, and texture mapping.

Panda3D − Panda3D is a game engine and graphics framework that provides a range of features for creating 3D games. It is designed to be easy to use and supports a range of platforms, including Windows, Mac, and Linux.

Pyglet − Pyglet is a cross-platform gaming library that provides a range of features for creating 2D and 3D games. It is designed to be fast and efficient, and provides a range of tools for handling graphics, sound, and input.

Ease of use − Many of these libraries are designed to be easy to use and learn, making them a good choice for beginners or developers who are new to game development.

Flexibility − These libraries provide a range of features and tools for creating games, which can make it easier to create games that are tailored to your specific needs and requirements.

Performance − Some of these libraries are designed to be fast and efficient, which can help improve the performance of your games.

Cross-platform support − Many of these libraries support a range of platforms and operating systems, which can help make your games more accessible to a wider audience.

Prerequisites

Before we dive into the details of creating a scrolling background in Pygame, let’s review some of the prerequisites.

pip install pygame

It is expected that the user will have access to any standalone IDE such as VS-Code, PyCharm, Atom or Sublime text.

Even online Python compilers can also be used such as chúng tôi Google Cloud platform or any other will do.

Updated version of Python. At the time of writing the article I have used 3.10.9 version.

Knowledge of the use of Jupyter notebook.

Familiarity with Pygame library

Basic understanding of 2D graphics and game development concepts

If you are not comfortable with any of these prerequisites, we recommend taking some time to get familiar with them before continuing.

Steps for creating a Scrolling Background

Creating a scrolling background involves several steps. We will go over each of them in detail and provide some real-world examples to help you get started.

Step 1: Setting up the game window

The first step to creating a scrolling background is to set up your game window. This can be done using the `pygame.display.set_mode()` function. Here is an example −

import pygame pygame.init() Set up game window screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("Scrolling Background Tutorial")

In this example, we import the Pygame library and initialize it. We then set the width and height of the game window to 800 pixels and 600 pixels, respectively. Finally, we set the `screen` variable to the newly created game window with the caption “Scrolling Background Tutorial”.

Step 2: Loading the background image

The next step is to load the background image that will be scrolled. This can be done using the `pygame.image.load()` function. Here is an example −

#Load background image background_img = pygame.image.load("background.jpg")

In this example, we load the image named “background.jpg” and store it in the `background_img` variable.

Step 3: Scrolling the background

The next step is to scroll the background image. This can be done by changing the position of the background image on the game window. Here is an example −

# Scroll the background scroll_x = 0 scroll_y = 0 background_x = 0 while True: for event in pygame.event.get(): if chúng tôi == pygame.QUIT: pygame.quit() # Scroll the background horizontally scroll_x -= 1 background_x -= 1 #Draw the background twice to create seamless scrolling effect screen.blit(background_img, (scroll_x, scroll_y)) screen.blit(background_img, (background_x, scroll_y)) #Reset the background position when it goes off screen if scroll_x <= -screen_width: scroll_x = screen_width if background_x <= -screen_width: background_x = screen_width pygame.display.update()

In this example, we set the initial position of the background image to `(0,0)`. We then create a `while` loop that will run continuously until the game is closed. Inside the `while` loop, we increment the `scroll_x` and `background_x` variables by `-1` to move the background image to the left. We then draw the background image twice using `screen.blit()` function. This creates a seamless scrolling effect.

Step 4: Adding game objects

The final step is to add game objects to the window. This can be done using the Pygame library’s various drawing functions. Here is an example −

#Add game objects player_img = pygame.image.load("player.png") player_x = 400 player_y = 300 while True: for event in pygame.event.get(): if chúng tôi == pygame.QUIT: pygame.quit() #Scroll the background horizontally scroll_x -= 1 background_x -= 1 #Draw the background twice to create seamless scrolling effect screen.blit(background_img, (scroll_x, scroll_y)) screen.blit(background_img, (background_x, scroll_y)) #Reset the background position when it goes off screen if scroll_x <= -screen_width: scroll_x = screen_width if background_x <= -screen_width: background_x = screen_width #Add game objects screen.blit(player_img, (player_x, player_y)) pygame.display.update()

In this example, we add a player object to the screen using the `screen.blit()` function. We also set the initial position of the player object to `(400,300)`.

Final Program,Code # libraries import pygame pygame.init() #Setting up the window screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("Scrolling Background Tutorial") #Load background image background_img = pygame.image.load("background.jpg") # Scroll the background scroll_x = 0 scroll_y = 0 background_x = 0 while True: for event in pygame.event.get(): if chúng tôi == pygame.QUIT: pygame.quit() # Scroll the background horizontally scroll_x -= 1 background_x -= 1 #Draw the background twice to create seamless scrolling effect screen.blit(background_img, (scroll_x, scroll_y)) screen.blit(background_img, (background_x, scroll_y)) #Reset the background position when it goes off screen if scroll_x <= -screen_width: scroll_x = screen_width if background_x <= -screen_width: background_x = screen_width pygame.display.update() #Add game objects player_img = pygame.image.load("player.png") player_x = 400 player_y = 300 while True: for event in pygame.event.get(): if chúng tôi == pygame.QUIT: pygame.quit() #Scroll the background horizontally scroll_x -= 1 background_x -= 1 #Draw the background twice to create seamless scrolling effect screen.blit(background_img, (scroll_x, scroll_y)) screen.blit(background_img, (background_x, scroll_y)) #Reset the background position when it goes off screen if scroll_x <= -screen_width: scroll_x = screen_width if background_x <= -screen_width: background_x = screen_width #Add game objects screen.blit(player_img, (player_x, player_y)) pygame.display.update() Output

In the above section we can see that there are two outputs which shows the transition or scrolling of the background image thus the program works correctly with proper and expected output.

Conclusion

In this tutorial, we covered the essential steps for creating a scrolling background in Pygame. We also provided real-world examples and code snippets to help you understand the concepts better. With this knowledge, you should be able to create engaging games that feature scrolling backgrounds. Happy coding!

You're reading Creating A Scrolling Background In Pygame

How To Make A Logo Background Transparent In Photoshop

If you often work with logos for your business, you may at some point need to make a logo background transparent in Photoshop. Depending on the appearance of your logo’s background, you can do this a few different ways. 

Once you’ve removed the background from a logo, you can set the export settings so that it stays transparent and then add it to other projects or save it for future use.

In this guide, you’ll learn how to remove the background from your logo and export it properly, regardless of your logo’s background color.

Making A Solid-Colored Logo Background Transparent In Photoshop

Removing a solid-colored background from a logo is easy and only takes a few steps. After making the background transparent, you’ll learn a quick way to check that the edges of the logo are smooth and clean them up if need be.

Step 1: Select The Magic Wand Tool (W) Step 2: Set The Magic Wand Settings

Next, you’ll want to be sure the settings are set so that you’ll be able to select the entire solid-colored background area. 

Once you’ve selected the Magic Wand Tool, head to the Options Bar and change the following settings:

Check the Contiguous option

Set the Sample Area (3×3 works fine for selecting a background, but you may want to try higher options like 11×11)

Set the Tolerance between 10-40, depending on your image 

You can go back and edit these settings later to see how they affect the selection, particularly around the edges of your logo, as different settings here will result in slightly different selections. 

If you have parts of the background inside your logo – such as inside the center of a circle or letter – and you want to remove them, leave the Contiguous box unchecked, and the selection will be made around any pixels that match the background color. 

To keep those areas as part of your logo, ensure the Contiguous box is checked. The selection will only be made around pixels that match the background color and sit next to each other (like in the example below).

Step 3: Select The Background

Notice that the insides of the infinity sign in my logo are not selected because I have left the Contiguous box checked. Again, you can uncheck this if you’d like those areas selected as well.

Step 4: Add A Layer Mask

This will add the selection to a Layer Mask, which you’ll see beside the Image Layer in the Layers Panel.

You’ll see the Layer Mask has cut out the logo rather than the background on your document. 

You can easily invert the mask by pressing Control + I (Win) or Command + I (Mac), and the logo will reappear with the background removed.

Step 5: Clean Up The Selection

In the Options Bar, you can resize your Sample Size to Point Sample for the best possible accuracy.

Finally, with the Layer Mask selected in the Layers Panel, press Alt + Delete (Win) or Option + Delete (Mac) to remove these areas from your mask.

This will make those areas transparent, like the rest of your logo’s background. Deselect the areas by pressing Control + D (Win) or Command + D (Mac).

Step 6: Clean Up The Edges

Scroll through the tabs until you see Global Refinements. Here, you can adjust the Smooth, Contrast, and Shift Edge settings until the edges have a smooth rather than pixelated appearance. 

Each logo will require something different. I’ll increase the Contrast and Smooth settings for the logo I’m working with and decrease the Shift Edge setting. Subtle adjustments are usually enough.

The edges appear sharper after the adjustments than before.

Before After

Step 7: Save A Copy

In the Save As window, set the File Format to PNG.

Making A Multi-Colored Logo Background Transparent In Photoshop

When working with a logo with a multi-colored or patterned background, you won’t be able to simply use the Object Selection Tool or the Magic Wand Tool. Still, you can easily remove the logo from its background in a few simple steps using Channels.

Step 1: Select A Channel Step 2: Duplicate The Channel

You’ll see a copy of your chosen channel at the bottom of the list.

Step 3: Open Levels

Now you can open the Levels window using the shortcut Control + L (Win) or Command + L (Mac).

Drag the levels in so that the darkest parts of the image are 100% black and the lightest parts become 100% white. You don’t need to bring the levels to the center; if you do, the image becomes too contrasted, and the logo’s edges start to fray. You can leave them when the colors are 100% black and white.

Step 4: Select The Logo

This will create an active selection around the logo in the image.

Step 5: Add A Layer Mask

This will add a Layer Mask to the image, which you’ll see in the Layers Panel sitting to the right of the picture.

The document shows that the layer mask has cut out the logo.

You can invert the layer mask so that the logo, not the background, is visible by pressing Control + I (Win) or Command + I (Mac). You’ll see the logo in the document and the background transparent.

Step 6: Clean Up The Edges

There is one final step you can take to ensure that you’ve successfully removed all of the background from the logo.

Name the Color Fill Layer and press OK. The Color Picker window will appear. I’ll drag the toggle to white just to make sure the edges of the logo are neat and clean them up a bit if they are pixelated.

The new fill layer will appear in the Layers Panel and on the document on top of the logo. Drag the Color Fill Layer beneath the Logo layer, so the logo sits in front.

From here, scroll until you see the Global Refinements section.

The settings that will help fix the edges the most are the Smooth setting, which smooths out the pixelation, and the Contrast setting, which will increase the contrast along the edge. You can play around with these until you’re content with how the edges look.

Before After

Step 7: Save A Copy

Again, you can save a copy of your logo once you’ve finished working on it. This allows you to come back and continue working in Photoshop or use the logo in a future project.

Additional Export Options For Transparent Logos In Photoshop

In the Export As window, you can resize your logo by entering a new Width and Height in the Image Size section.

However, you can reduce the size as much as you’d like without compromising quality. This will allow you to save the logo and apply it to projects that require a smaller size, such as for the header of a website.

Finally, ensure the File Format is set to PNG and the Transparency box is checked.

Happy Editing!

Basics Of Creating A Mobile Site

As the future of the web and the world is going towards mobile, every webmaster needs to have a mobile version of their site which is simple and effective. Your mobile site should be compact and convenient to the users and search engines and here is a crash course on creating a mobile site and some important points before you go live with your mobile site. Since mobile search engines are different from normal desktop search engines users will see a different result in mobile hence optimizing your mobile site for search engines is also an important factor to derive traffic.

Steps in Creating Your Mobile Site

The basics steps in creating your mobile site differ based on the builder tool you choose. Here are the list of common steps to be carried out after your regular site is imported into a mobile site builder tool and before publishing your mobile site.

Sample Mobile Site

1. Select Your Layout and Pages

Select your mobile layout and pages you feel important to shown to the mobile users. A typical mobile site will have the following pages:

Mobile Home

Products

Services

Blog Feed

About Us

Contact Us

Make your site is compact by using simple navigation styles to help the user reach your content easily. You can also link your social connection in your mobile navigation links so that the users can easily visit your social content and like or follow you. It is also a good idea to try out drag and drop website builder tools like Duda to check if that can make your task simpler.

2. Edit Your Content

Though most of the compatible contents are automatically imported into your mobile site, you need to delete and add the content suitable for mobiles. Here are some important points to be taken care:

Remove large text contents imported from your regular site and provide only the important content in a compact manner

Make use of bulleted list to shorten big paragraphs

Adjust your images to fit and load faster in mobile devices

3. Set Your Redirect

The important point after you gone live with your mobile site is to set a redirect from your regular site. This is a piece of code provided by your mobile site builder to be placed between the HEAD tags in a home page of your regular website. When a user visits your regular URL from a mobile device this piece of code automatically redirects the user to your mobile site.

Make sure you provide a link to your desktop site so that the users can go back to your regular site if not convenient with your mobile site. Let the user choose the version he prefers to see and the option to choose to choose between mobile and desktop sites at any point of time.

4. Test Your Mobile Site

After you setup a redirect it is highly recommended to open your regular website in various phone models. This ensures that the redirect is working fine as well as your site looks perfect in various phones like Android mobile, Android tabs, Apple iPhone, Apple iPad and Windows phones. In case of any issues you can adjust your site and republish it accordingly.

Test Your Mobile Site

5. Mobile Site Tracking

In order to monitor and track your mobile sites separately from your regular site, you need to submit your mobile Sitemap in your Webmaster Tools account. This helps the mobile search engines to crawl and index your mobile pages easily. You can also set your Google Analytics tracking code in your mobile site if you want to track your conversions and traffic data.

Note: Most of the WordPress themes are fluid and responsive in nature which automatically fits your content to the available width of the screen. If you are creating a separate mobile site for AMP or any other reasons, make sure to cache the mobile pages separately instead of serving the same desktop version of cached pages to avoid layout mismatches.

Creating Better People: Secd Can Make A Difference

People often ask me what evidence there is to support the view that our schools should promote social, emotional, and character development in our students. They seem especially interested in whether SECD actually helps shape the character and behavior of students over time.

Because many educators lose track of former students as they move on in grades and grow into adulthood, it’s natural for them to wonder, “Did the SECD curriculum really help my students and do any good in their lives?” A recent study published by the research team at the Seattle Social Development Project reminds us that, when delivered effectively, SECD interventions in schools have long-term benefits.

The Results of an Earlier Study

The Rutgers Social-Emotional Learning Lab, of which I am director, carried out one of the earliest peer-reviewed studies on the benefits of SECD. In the study, the group compared three cohorts of students who received social decision-making/social-problem-solving (SDM/SPS) lessons in elementary school. The groups received varying amounts of the program’s components, ranging from two years to five years, with some follow-up in high school after concluding the intervention. Educators used students who received no treatment as a control group.

Results from this study indicate that ninth-grade students who had received interventions drank significantly less alcohol, had fewer self-destructive or identity problems, earned higher scores in overall social competence, exhibited a higher level of membership and participation in positive social organizations and nonsports activities, and did better on-the-job work.

Tenth-grade students who hadn’t participated, meanwhile, had significantly higher rates of vandalizing school property, attacking persons with intent to injure, hitting or threatening other students, self-destructive or identity problems, and unpopularity than students who went through the program. They also showed lower scores in overall social competence. Eleventh-grade students in the control group had significantly higher rates of vandalizing their parent’s property, hitting or threatening their parents, and using chewing tobacco than students in the program.

Across grades, male students in the control groups significantly exceeded male students in the program in rates of petty theft and buying alcohol. The findings also indicated that students who were in the higher-fidelity program generally showed better goal attainment than those in the lower-fidelity program.

Further Findings

David Hawkins, founding director of the University of Washington’s Social Development Research Group, says that fifteen years after the Seattle Social Development Program conducted its evidence-based SECD intervention, young adults ages twenty-four and twenty-seven who were part of the intervention reported better mental and sexual health and higher educational and economic achievement than a control group of young adults who didn’t receive the intervention.

As lead author of the study, Hawkins told Science Daily in a recent interview, “The effects of working with children in elementary school show up in their teen years as their rates of violence, heavy alcohol use, and dropping out of school are reduced. By age twenty-one, more of them have completed high school and have better jobs. And by ages twenty-four and twenty-seven, they are above the median in socioeconomic status and education, and they are having fewer mental-health and sexual-health problems.”

The study involved 598 students from fifteen Seattle public schools that serve high-crime neighborhoods. The participants were divided into three groups. One group of 146 students received the intervention in grades 1-6. A second group of 251 students received a partial intervention in only grades 5-6. And the third group of 201 students did not receive any training from the program.

Hawkins reported that the dosage effect found in the SDM/SPS program — and in earlier studies of the Seattle program — was still evident. Children who received the full intervention in elementary school showed the strongest effects and the most positive functioning when followed up. Those receiving the partial intervention showed lesser effects, though they were generally better than the no-exposure control group. The findings indicate that those who received the full intervention had significantly fewer sexually transmitted diseases and reported higher income, increased responsibilities at work, and more community involvement. However, the full intervention had no effect on reducing substance abuse or cutting criminal behavior in young adulthood.

Said Hawkins, “The real value in following people over time is that we get to see how what we do in childhood affects their lives and has enduring effects as they change. We can’t know how one phase of development affects the next step unless we follow people over time.”

The Power of SECD

These studies complement other data — from a meta-analysis completed recently by the Collaborative for Academic, Social, and Emotional Learning — that reveal the positive follow-up benefits of SECD programs for students in both academics and mental health. The consistent message of these studies, however, is that the “dose” matters and that comprehensive, coordinated, multiyear efforts at SECD are what yield positive results.

This is why my organization, Developing Safe and Civil Schools, is working with New Jersey schools to ensure that they are carrying out their programs in problem prevention, promotion of social and emotional competence, positive youth and character development, and school-climate improvement in ways that will yield the desired effects. Too many schools are doing more than they need to, but with not enough efficiency and coordination to achieve the desired academic and behavioral outcomes. The evidence suggests that we can do better without doing much more.

What do you think about SECD efforts in public schools? Please share your thoughts.

Creating Interactive Visualizations Using Plotly In Python

Introduction

In today’s world, every second the data keeps on getting bigger and bigger. In order to understand the data quickly and to draw insights, data visualization becomes necessary.

For e.g. consider a case where you are asked to illustrate crucial sales aspects (like sales performance, target, revenue, acquisition cost, etc.) from huge amounts of sales data, which one would you prefer:

Exploring the data using different types of sales graphs and charts

Obviously, you would prefer graphs and charts. So data visualization plays a key role in data exploration and data analysis.

Data Visualization is the technique to represent the data/information in a pictorial or graphical format. It enables the stakeholders and decision-makers to analyze and explore the data visually and uncover deep insights.

“Visualization gives you answers to questions you didn’t know you had.” – Ben Schneiderman

Benefits of Data Visualization

Helps in data analysis, data exploration and makes the data more understandable.

Summarises the complex quantitative information in a small space.

Helps in discovering the latest trends, hidden patterns in the data.

Identifies the relationships/correlations between the variables.

Helps in examining the areas that need attention or improvement.

Why Plotly?

There are several libraries available in Python like Matplotlib, Seaborn, etc. for data visualization. But they render only the static images of the charts/plots and due to this, many crucial things get lost in the visualization. Wouldn’t it be amazing if we could interact better with the charts by hovering in (or) zooming in? Plotly allows us to do the same.

Plotly is an open-source data visualization library to create interactive and publication-quality charts/graphs.

Plotly offers implementation of many different graph types/objects like line plot, scatter plot, area plot, histogram, box plot, bar plot, etc.

Plotly supports interactive plotting in commonly used programming languages like Python, R, MATLAB, Javascript, etc.

In this post, we will cover the most commonly used graph types using Plotly. So let’s get started using the Cars93 dataset available on Kaggle.

The dataset contains 27 car parameters (like manufacturer, make, price, horsepower, engine size, weight, cylinders, airbags, passengers, etc.) of 93 different cars.

The dataset looks like this:

Installing Plotly

In order to install Plotly, use the following command in the terminal.

pip install plotly

Plotly comes with few modules to create visualizations, i.e. giving us a choice of how to utilize it.

express: A high-level interface for creating quick visualizations. It’s a wrapper around Plotly graph_objects module.

graph_objects: A low-level interface to figures, traces, and layouts. It’s highly customizable in general for different graphs/charts.

figure_factory: Figure Factories are dedicated functions for creating very specific types of plots. It was available prior to the existence of Plotly express, therefore deprecated as “legacy”.

Having known and installed Plotly, now let’s plot different graphs/charts using it.

1. Box Plot

A box plot (or box-and-whisker plot) is a standardized way to display the distribution of quantitative data based on a Five-Point summary (minimum, first quartile(Q1), median(Q2), third quartile(Q3), and maximum).

The box extends from the Q1 to Q3 quartile values, whereas the whiskers extend from the edges of the box to the 1.5*IQR. IQR = (Q3 – Q1)

The best thing about this visualization is that we can start interacting with it by hovering in to see the quantiles values.

Similarly, we can customize it as per the requirement. For e.g. drawing a boxplot of Price for each AirBags type.

2. Histogram

A histogram is an accurate representation of the distribution of numerical data.

To construct a histogram, follow these steps −

Bin

(or bucket) the range of values – Divide the entire range of values into a series of intervals.

Count

how many values fall into each interval.

Let’s draw a histogram for cars’ Horsepower feature.

Here, X-axis is about bin ranges of Horsepower whereas Y-axis talks about frequency/count in each bin.

3. Density Plot

The density plot is a variation of a histogram, where instead of representing the frequency on the Y-axis, it represents the PDF (Probability Density Function) values.

It’s helpful in determining the Skewness of the variable visually.

Also, useful in assessing the importance of a continuous variable for a classification problem.

The density plot of Horsepower based on AirBags type is as shown below.

4. Bar Chart

A bar chart represents categorical data with rectangular bars with weights proportional to the values that they represent.

A bar plot shows comparisons among discrete categories.

The bar chart of the Type feature is as shown below.

Similarly, we can customize it to display MPG.city mean on the Y-axis, instead of displaying count.

5. Pie Chart

Pie Chart is used to represent the numerical proportion of the data in a circular graph.

The whole area of the chart represents 100% of the data, the arc length of each slice represents the relative percentage part of the whole.

The pie chart of the Type feature is as shown below.

6. Scatter Plot

A scatter plot uses dots to represent values for two different numeric variables.

It is really helpful in observing the relationship between two numeric variables.

Let’s draw a scatter plot, in order to assess the relationship between Horsepower and MPG.city.

From this plot, we can observe that as the Horsepower increases, MPG in the city decreases.

Plotly also provides a way to draw 3D scatter plots. Let’s draw the same using Horsepower, MPG.city, and Price features.

Similarly, we can draw a scatter plot matrix (a grid/matrix of scatter plots) to assess pairwise relationships for each combination of variables.

7. Line Chart

A line chart is a type of chart that displays information as a series of data points called ‘markers’ connected by straight line segments.

It is similar to a scatter plot except that the measurement points are ordered (typically by their x-axis value) and joined with straight line segments.

Line graphs are usually used to find relationships between two numeric variables or to visualize a trend in time series data.

Let’s draw a scatter plot, in order to assess the relationship between Horsepower and MPG.city.

8. Heatmap

A heatmap is a two-dimensional graphical representation of data whereas matrix values are represented in different shades of colors.

A heatmap aims to provide a color-coded visual summary of data/information.

Seaborn allows annotated heatmaps as well.

Let’s draw a heatmap to represent the correlation matrix of cars93 data.

9. Violin Plot

Violin plots are similar to box plots, except that they also show the probability density of the data at different values. In other words, the violin plot is a combination of a box plot and density plot.

Broader sections of the violin plot indicate higher probability, whereas the narrow sections indicate lower probability.

The Violin plot of the Price feature is shown below.

Similarly, we can customize it using Plotly to display the box and all the data points.

10. Word Cloud

Word Cloud is a visualization technique to represent the frequency of words within a given text segment.

The size of a word indicates how frequently it occurs in the text. The bigger the size, the greater the importance(frequency), whereas the smaller the size, the lesser the importance(frequency).

Word clouds are often used for representing the frequency of words within text documents, reports, website data, public speeches, etc.

Word cloud of a chosen text document is as shown below.

End Notes

The media shown in this article are not owned by Analytics Vidhya and is used at the Author’s discretion. 

Related

Defocus The Background In Android Smartphone Camera Pics

The new HTC One M8 has two cameras, allowing it to do a number of cool tricks, the most notable of which being the ability to blur the background while bringing a subject into focus similar to a DSLR camera. The thing is, many smartphones can also do this with the right combination of software. Some apps have attempted to offer this functionality in the Play Store for a while now with mixed results. Here’s a look at which flagship phones or apps are able to defocus the background and the approach they take to do so.

1. Google Camera

Google recently uploaded the Google Camera app to the Play Store and made it install-able on a large number of devices. This app replaces the default software that comes on Nexus products or any devices running stock Android. It simplifies the interface, making it more intuitive and easy-to-use overall. But, in the midst of the changes, Google added one stand out new feature – Lens Blur. This feature focuses on one object and blurs the background. Users can then edit the photo later, changing where the focus should be and blurring everything else. Since this app comes from Google, it is probably the most high profile way for users to defocus backgrounds regardless of which device they own, as long as it’s running Android 4.4 or higher.

2. Sony Background Defocus

Sony Background Defocus is available exclusively for Sony Xperia devices. It works by taking two photos of an object, then after the user has selected which object should be in focus, blurs the second image, resulting in a background that looks out of focus. The app provides options to adjust the blur level and comes with a pretty clean UI, making it an attractive option for people who own a Sony Android device.

3. Galaxy S5 “Selective Focus”

The new Galaxy S5 also has support for background defocusing out of the box. The feature, “selective focus,” has to be selected before taking a shot. Users select the toggle and then take a picture as they normally would. The phone will then take a number of shots and process them. It will ask whether the image should have near focus, far focus, or everything focused. Afterwards, users can edit these images, changing which object is in focus. This app is not available on Google Play.

4. AfterFocus

AfterFocus is one app that has been in the Play Store for quite a while, and it exemplifies the old-fashioned approach software previously took towards defocusing the background. Rather than doing it automatically, it requires users to draw a line around the part of the image that should remain in focus, along with meticulously highlighting which parts of the background should be blurred. The end result is typically less than convincing without a good deal of work, and there’s no forgetting just how artificial the entire process is when using this app.

Final Thoughts

These offerings aren’t quite as versatile as the HTC One M8, which is able to defocus any image the phone has taken, not just those that were selected to be blurred beforehand. This is thanks to the depth information that the phone’s second camera saves about each image. Nevertheless, this isn’t too big a deal with a little bit of planning. With the right device or software, you no longer need an expensive DSLR camera to get a convincing end result.

Bertel King, Jr.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

Update the detailed information about Creating A Scrolling Background In Pygame on the Moimoishop.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!