{"id":3725,"date":"2022-01-24T07:05:41","date_gmt":"2022-01-24T07:05:41","guid":{"rendered":"https:\/\/cloudxlab.com\/blog\/?p=3725"},"modified":"2022-01-24T07:08:05","modified_gmt":"2022-01-24T07:08:05","slug":"how-to-use-numpy-meshgrid-to-generate-data","status":"publish","type":"post","link":"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/","title":{"rendered":"How to use Numpy Meshgrid to generate data?"},"content":{"rendered":"\n<p>When you are generating data, the Meshgrid function of Numpy helps us to generate the coordinates data from individual arrays.<\/p>\n\n\n\n<p>Say, you have a set of values of x 0.1, 0.2, 0.3, 0.4. You want to generate all possible points by combining these four values with say three values for y: 4, 5, 6.<\/p>\n\n\n\n<p>This can be done very easily by using <code>meshgrid<\/code> function of Numpy as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">import numpy as np\nx, y = np.meshgrid([0.1, 0.2, 0.3, 0.4], [4, 5, 6])\nimport matplotlib.pyplot as plt\nplt.scatter(x, y)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"378\" height=\"248\" src=\"https:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2022\/01\/image.png\" alt=\"\" class=\"wp-image-3726\"\/><figcaption>The Scatter plot generated after meshgrid<\/figcaption><\/figure>\n\n\n\n<p>To learn more about it, please visit <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.meshgrid.html\">Numpy Meshgrid Reference<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are generating data, the Meshgrid function of Numpy helps us to generate the coordinates data from individual arrays. Say, you have a set of values of x 0.1, 0.2, 0.3, 0.4. You want to generate all possible points by combining these four values with say three values for y: 4, 5, 6. This &hellip; <a href=\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to use Numpy Meshgrid to generate data?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use Numpy Meshgrid to generate data? | CloudxLab Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Numpy Meshgrid to generate data? | CloudxLab Blog\" \/>\n<meta property=\"og:description\" content=\"When you are generating data, the Meshgrid function of Numpy helps us to generate the coordinates data from individual arrays. Say, you have a set of values of x 0.1, 0.2, 0.3, 0.4. You want to generate all possible points by combining these four values with say three values for y: 4, 5, 6. This &hellip; Continue reading &quot;How to use Numpy Meshgrid to generate data?&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudxLab Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cloudxlab\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-24T07:05:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-24T07:08:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2022\/01\/image.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CloudxLab\" \/>\n<meta name=\"twitter:site\" content=\"@CloudxLab\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"1 minute\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#website\",\"url\":\"https:\/\/cloudxlab.com\/blog\/\",\"name\":\"CloudxLab Blog\",\"description\":\"Learn AI, Machine Learning, Deep Learning, Devops &amp; Big Data\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/cloudxlab.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2022\/01\/image.png\",\"contentUrl\":\"https:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2022\/01\/image.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#webpage\",\"url\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/\",\"name\":\"How to use Numpy Meshgrid to generate data? | CloudxLab Blog\",\"isPartOf\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#primaryimage\"},\"datePublished\":\"2022-01-24T07:05:41+00:00\",\"dateModified\":\"2022-01-24T07:08:05+00:00\",\"author\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/#\/schema\/person\/4835f1b3d5000626cb15e9311d748e09\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/\",\"url\":\"https:\/\/cloudxlab.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/how-to-use-numpy-meshgrid-to-generate-data\/#webpage\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#\/schema\/person\/4835f1b3d5000626cb15e9311d748e09\",\"name\":\"Sandeep Giri\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1393214840cf7455bb4cba055cb30468?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1393214840cf7455bb4cba055cb30468?s=96&d=mm&r=g\",\"caption\":\"Sandeep Giri\"},\"sameAs\":[\"https:\/\/cloudxlab.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/3725"}],"collection":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/comments?post=3725"}],"version-history":[{"count":4,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/3725\/revisions"}],"predecessor-version":[{"id":3732,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/3725\/revisions\/3732"}],"wp:attachment":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/media?parent=3725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/categories?post=3725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/tags?post=3725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}